From 9851a17ffeb335cb27fe157980160e595276cf7f Mon Sep 17 00:00:00 2001 From: Veselin Nikolov Date: Tue, 17 Jul 2018 07:52:19 +0300 Subject: [PATCH] test: add tests for Slider._adjustValue --- test/javascript/components/slider.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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'); -- 2.47.2