]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
test: add tests for Slider._adjustValue 11409/head
authorVeselin Nikolov <vesoNikolov@gmail.com>
Tue, 17 Jul 2018 04:52:19 +0000 (07:52 +0300)
committerVeselin Nikolov <vesoNikolov@gmail.com>
Tue, 17 Jul 2018 04:52:19 +0000 (07:52 +0300)
test/javascript/components/slider.js

index 364919af2f3e29fd7ea6aec6ba3ea619d362494a..9c1480aca750ce540cb602dc3a529f69bf051be5 100644 (file)
@@ -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');