From: Veselin Nikolov Date: Tue, 17 Jul 2018 04:52:19 +0000 (+0300) Subject: test: add tests for Slider._adjustValue X-Git-Tag: v6.6.0~3^2~127^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9851a17ff;p=thirdparty%2Ffoundation%2Ffoundation-sites.git test: add tests for Slider._adjustValue --- diff --git a/test/javascript/components/slider.js b/test/javascript/components/slider.js index 364919af2..9c1480aca 100644 --- a/test/javascript/components/slider.js +++ b/test/javascript/components/slider.js @@ -153,6 +153,30 @@ describe('Slider', function() { }); }); + describe('adjustValue()', function() { + it('handles positive values', function() { + $html = $(template).appendTo('body'); + plugin = new Foundation.Slider($html, {}); + + plugin._adjustValue(null, 1).should.equal(1); + plugin._adjustValue(null, 2).should.equal(2); + plugin._adjustValue(null, 1.2).should.equal(1); + plugin._adjustValue(null, 1.9).should.equal(2); + plugin._adjustValue(null, 1.5).should.equal(2); + }); + + it('handles negative values', function() { + $html = $(template).appendTo('body'); + plugin = new Foundation.Slider($html, {}); + + plugin._adjustValue(null, -1).should.equal(-1); + plugin._adjustValue(null, -2).should.equal(-2); + plugin._adjustValue(null, -1.2).should.equal(-1); + plugin._adjustValue(null, -1.9).should.equal(-2); + plugin._adjustValue(null, -1.5).should.equal(-1); + }); + }); + describe('keyboard events', function() { it('sets value to minimum using HOME', function() { $html = $(template).appendTo('body');