From: Sean Timm Date: Sat, 1 Feb 2014 00:09:48 +0000 (-0700) Subject: Fixed argument passing for Foundation spies and added some basic Interchange tests... X-Git-Tag: v5.1.0~29^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F4228%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Fixed argument passing for Foundation spies and added some basic Interchange tests. HTML partials appear to be having some issues, so one of the tests is disabled until I have a chance to figure out what is happening with them. --- diff --git a/spec/abide/abide.js b/spec/abide/abide.js index 584b67edc..23a219e39 100644 --- a/spec/abide/abide.js +++ b/spec/abide/abide.js @@ -6,7 +6,7 @@ describe('abide:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/accordion/accordion.js b/spec/accordion/accordion.js index 6ff01ccbd..5f85b50bf 100644 --- a/spec/accordion/accordion.js +++ b/spec/accordion/accordion.js @@ -6,7 +6,7 @@ describe('accordion:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/alert/alert.js b/spec/alert/alert.js index 990597b5d..d82d9fa27 100644 --- a/spec/alert/alert.js +++ b/spec/alert/alert.js @@ -6,7 +6,7 @@ describe('alert:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/clearing/clearing.js b/spec/clearing/clearing.js index 4aeaa97de..758973ce5 100644 --- a/spec/clearing/clearing.js +++ b/spec/clearing/clearing.js @@ -6,7 +6,7 @@ describe('clearing:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/dropdown/dropdown.js b/spec/dropdown/dropdown.js index 0d285d39e..1952ae6ce 100644 --- a/spec/dropdown/dropdown.js +++ b/spec/dropdown/dropdown.js @@ -6,7 +6,7 @@ describe('dropdown:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/framework/framework.js b/spec/framework/framework.js index 404039810..68d4ccd40 100644 --- a/spec/framework/framework.js +++ b/spec/framework/framework.js @@ -6,7 +6,7 @@ describe('Foundation Framework:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/interchange/basic.html b/spec/interchange/basic.html new file mode 100644 index 000000000..acea6c693 --- /dev/null +++ b/spec/interchange/basic.html @@ -0,0 +1,3 @@ +
+

DEFAULT

+
diff --git a/spec/interchange/interchange.js b/spec/interchange/interchange.js index 92a54eba1..97bca03bd 100644 --- a/spec/interchange/interchange.js +++ b/spec/interchange/interchange.js @@ -6,9 +6,55 @@ describe('interchange:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); + + spyOn($, 'get').andCallFake(function(path, callback) { + switch(path) { + case 'default.html': + callback('

DEFAULT

'); + case 'medium.html': + callback('

MEDIUM

'); + case 'large.html': + callback('

LARGE

'); + } + }); }); + + describe('when below the large breakpoint', when_not('large', function() { + describe('when below the medium breakpoint', when_not('medium', function() { + describe('with html content interchange', function() { + beforeEach(function() { + document.body.innerHTML = __html__['spec/interchange/basic.html']; + }); + + it('shows the default html content', function() { + $(document).foundation(); + + expect($('[data-interchange]').length).toBe(1); + expect($('#medium').length).toBe(0); + expect($('#large').length).toBe(0); + }); + }); + })); + })); + + describe('when above the large breakpoint', when('large', function() { + describe('with html content interchange', function() { + beforeEach(function() { + document.body.innerHTML = __html__['spec/interchange/basic.html']; + }); + + // Disabling for now... HTML partials may be misbehaving. + xit('shows the large html content', function() { + $(document).foundation(); + + expect($('#default').length).toBe(0); + expect($('#medium').length).toBe(0); + expect($('#large').length).toBe(1); + }); + }); + })); }); diff --git a/spec/joyride/joyride.js b/spec/joyride/joyride.js index 48a8f100b..521780ef0 100644 --- a/spec/joyride/joyride.js +++ b/spec/joyride/joyride.js @@ -6,7 +6,7 @@ describe('joyride:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/magellan/magellan.js b/spec/magellan/magellan.js index a202c561b..64af88258 100644 --- a/spec/magellan/magellan.js +++ b/spec/magellan/magellan.js @@ -6,7 +6,7 @@ describe('magellan:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/offcanvas/offcanvas.js b/spec/offcanvas/offcanvas.js index 484e89691..6528620bf 100644 --- a/spec/offcanvas/offcanvas.js +++ b/spec/offcanvas/offcanvas.js @@ -6,7 +6,7 @@ describe('offcanvas:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/orbit/orbit.js b/spec/orbit/orbit.js index 1b39c4fac..ad19a5930 100644 --- a/spec/orbit/orbit.js +++ b/spec/orbit/orbit.js @@ -6,7 +6,7 @@ describe('orbit:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/reveal/reveal.js b/spec/reveal/reveal.js index f03cfea11..5e5066823 100644 --- a/spec/reveal/reveal.js +++ b/spec/reveal/reveal.js @@ -6,7 +6,7 @@ describe('reveal:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/tab/tab.js b/spec/tab/tab.js index 2595f26bc..ebe8f5da7 100644 --- a/spec/tab/tab.js +++ b/spec/tab/tab.js @@ -6,7 +6,7 @@ describe('tab:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/tooltip/tooltip.js b/spec/tooltip/tooltip.js index 70b4124c4..2acce3ca6 100644 --- a/spec/tooltip/tooltip.js +++ b/spec/tooltip/tooltip.js @@ -6,7 +6,7 @@ describe('tooltip:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; }); diff --git a/spec/topbar/topbar.js b/spec/topbar/topbar.js index a334ac8e3..9bd1c93fb 100644 --- a/spec/topbar/topbar.js +++ b/spec/topbar/topbar.js @@ -6,7 +6,7 @@ describe('topbar:', function() { var origFunc = $.fn.foundation; spyOn($.fn, 'foundation').andCallFake(function() { - var result = origFunc.apply(this); + var result = origFunc.apply(this, arguments); jasmine.Clock.tick(1000); // Let things settle... return result; });