]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Add (some) tests for foundation.core.js
authorGeoff Kimball <geoff@zurb.com>
Tue, 1 Mar 2016 19:43:15 +0000 (11:43 -0800)
committerGeoff Kimball <geoff@zurb.com>
Tue, 1 Mar 2016 19:43:15 +0000 (11:43 -0800)
test/javascript/index.html
test/javascript/util/core.js [new file with mode: 0644]

index 8ea4db8195e87705dbcc9517e80ec6105e63623d..784f65d984ef770145a0b9f424f76409cc7df927 100644 (file)
@@ -17,8 +17,8 @@
     <script src="lib/chai-jquery.js"></script>
     <script src="lib/sinon.js"></script>
     <script>mocha.setup('bdd');</script>
+    <script src="util/core.js"></script>
     <script src="components/toggler.js"></script>
-    <script src="tests.js"></script>
     <script>
       mocha.run();
     </script>
diff --git a/test/javascript/util/core.js b/test/javascript/util/core.js
new file mode 100644 (file)
index 0000000..60bf26b
--- /dev/null
@@ -0,0 +1,83 @@
+chai.should();
+
+describe('Foundation core', function() {
+  it('exists on the window', function() {
+    (window.Foundation).should.be.an('object');
+  });
+
+  it('is a jQuery prototype function', function() {
+    ($.fn.foundation).should.to.be.a('function');
+  });
+
+  describe('rtl()', function() {
+    it('detects the text direction on the document', function() {
+      (Foundation.rtl()).should.be.false;
+      $('html').attr('dir', 'rtl');
+
+      (Foundation.rtl()).should.be.true;
+      $('html').attr('dir', 'ltr');
+    });
+  });
+
+  describe('plugin()', function() {
+    afterEach(function() {
+      delete Foundation._plugins['plugin'];
+      delete Foundation.Plugin;
+    });
+
+    it('adds Foundation plugins', function() {
+      function Plugin() {}
+      Foundation.plugin(Plugin, 'Plugin');
+
+      (Foundation._plugins['plugin']).should.be.a('function');
+      (Foundation.Plugin).should.be.a('function');
+    });
+
+    it('uses the name of the Plugin class/function if one is not provided', function() {
+      function Plugin() {}
+      Foundation.plugin(Plugin);
+
+      (Foundation._plugins['plugin']).should.be.a('function');
+      (Foundation.Plugin).should.be.a('function');
+    });
+  });
+
+  describe('registerPlugin()', function() {
+    it('registers a new instance of a plugin');
+  });
+
+  describe('unregisterPlugin()', function() {
+    it('un-registers a plugin being destroyed');
+  });
+
+  xdescribe('reInit()', function() {
+
+  });
+
+  describe('GetYoDigits()', function() {
+    it('generates a random ID matching a given length', function() {
+      var id = Foundation.GetYoDigits(6);
+
+      id.should.be.a('string');
+      id.should.have.lengthOf(6);
+    });
+
+    it('can append a namespace to the number', function() {
+      var id = Foundation.GetYoDigits(6, 'plugin');
+
+      id.should.contain('-plugin');
+    });
+  });
+
+  describe('reflow()', function() {
+  });
+
+  describe('getFnName()', function() {
+  });
+
+  describe('transitionEnd()', function() {
+  });
+
+  describe('throttle()', function() {
+  });
+});