]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Added util to mock keyboard events for orbit unit tests.
authorMarius Olbertz <marius.olbertz@gmail.com>
Sat, 14 Jan 2017 09:25:46 +0000 (10:25 +0100)
committerMarius Olbertz <marius.olbertz@gmail.com>
Sat, 14 Jan 2017 09:25:46 +0000 (10:25 +0100)
test/javascript/components/orbit.js

index 1a008441c8f8d011183d066576d0289d7e77e9af..6cd15ba5031a6fc2fad9fcffd3be544811c41f3f 100644 (file)
@@ -194,4 +194,27 @@ describe('Orbit', function() {
       }, 201);
     });
   });
+
+  describe('keyboard events', function() {
+    it('moves switches to next slide using ARROW_RIGHT', function() {
+      $html = $(template).appendTo('body');
+      plugin = new Foundation.Orbit($html, {});
+      let spy = sinon.spy(plugin, 'changeSlide');
+
+      plugin.$wrapper.focus()
+        .trigger(window.mockKeyboardEvent('ARROW_RIGHT'));
+
+      sinon.assert.calledWith(spy, true);
+    });
+    it('moves switches to previous slide using ARROW_LEFT', function() {
+      $html = $(template).appendTo('body');
+      plugin = new Foundation.Orbit($html, {});
+      let spy = sinon.spy(plugin, 'changeSlide');
+
+      plugin.$wrapper.focus()
+        .trigger(window.mockKeyboardEvent('ARROW_LEFT'));
+
+      sinon.assert.calledWith(spy, false);
+    });
+  });
 });
\ No newline at end of file