]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: slider _value() tests to assert positive/negative values 11663/head
authorVitaliy Filipov <altras@gmail.com>
Wed, 23 Jan 2019 21:20:03 +0000 (23:20 +0200)
committerVitaliy Filipov <altras@gmail.com>
Wed, 23 Jan 2019 21:20:03 +0000 (23:20 +0200)
test/javascript/components/slider.js

index 9c1480aca750ce540cb602dc3a529f69bf051be5..7d73681c1a680235225be47298a883cb408d3336 100644 (file)
@@ -153,6 +153,40 @@ describe('Slider', function() {
     });
   });
 
+  describe('_value()', function() {
+    it('handles positive values', function() {
+      $html = $(template).appendTo('body');
+      plugin = new Foundation.Slider($html, {
+        initialStart: 0,
+        end: 10,
+        start: 0,
+        vertical: true
+      });
+
+      plugin._value(0.5237916657475017).should.equal(4.762083342524983);
+      plugin._value(0.009882861617877391).should.equal(9.901171383821225);
+      plugin._value(0.9840506496657916).should.equal(0.1594935033420839);
+      plugin._value(0.7327435970969094).should.equal(2.672564029030906);
+      plugin._value(0.2569544020648122).should.equal(7.430455979351878);
+    });
+
+    it('handles negative values', function() {
+      $html = $(template).appendTo('body');
+      plugin = new Foundation.Slider($html, {
+        initialStart: 0,
+        end: 5,
+        start: -5,
+        vertical: true
+      });
+
+      plugin._value(0.8372195627716132).should.equal(-3.372195627716133);
+      plugin._value(0.012706536365842359).should.equal(4.872934636341577);
+      plugin._value(0.9925216739096865).should.equal(-4.925216739096864);
+      plugin._value(0.8202775142838235).should.equal(-3.2027751428382345);
+      plugin._value(0.2103637687233902).should.equal(2.8963623127660982);
+    });
+  });
+
   describe('adjustValue()', function() {
     it('handles positive values', function() {
       $html = $(template).appendTo('body');
@@ -260,4 +294,4 @@ describe('Slider', function() {
       plugin.$handle.should.have.attr('aria-valuenow', (10 - 1 * 10).toString());
     });
   });
-});
\ No newline at end of file
+});