+++ /dev/null
-<!DOCTYPE HTML>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title></title>
-</head>
-<body>
-Simple Iframe
-</body>
-</html>
+++ /dev/null
-<div class="deck-container">
- <div class="slide1"></div>
-
- <div class="slide2 slide3 slide4">
- </div>
-
- <div class="slide5">
- <iframe src='fixtures/iframe_simple.html'></iframe>
- </div>
-
- <div class='slide6'>
-
- </div>
-
- <div class="slide7">
- <iframe></iframe>
- </div>
-
- <div class="slide8 slide9 slide10"></div>
-
- <p class="deck-status">
- <span class="deck-status-current"></span>
- /
- <span class="deck-status-total"></span>
- </p>
-
- <form action="." method="get" class="goto-form">
- <label for="goto-slide">Go to slide:</label>
- <input type="number" name="slidenum" id="goto-slide" value="">
- <input type="submit" value="Go">
- </form>
-</div>
@@ -51,7 +51,7 @@ describe('Deck JS', function() {
$.deck('go', 5);
expect($.deck('getSlide')).toHaveClass('slide1');
});
-
+
it('should go nowhere if id does not exist', function() {
$.deck('go', 'i-dont-exist');
expect($.deck('getSlide')).toHaveClass('slide1');
@@ -123,13 +123,13 @@ describe('Deck JS', function() {
expect(slides).toEqual(expectation);
});
});
-
+
describe('getContainer()', function() {
it('should return a jQuery object with the container element(s)', function() {
expect($.deck('getContainer')).toBe(defaults.selectors.container);
});
});
-
+
describe('getOptions()', function() {
it('should return the current options object', function() {
expect($.deck('getOptions')).toEqual(defaults);
@@ -229,7 +229,7 @@ describe('Deck JS', function() {
$d.trigger(e);
expect($.deck('getSlide')).toHaveClass('alt-slide1');
});
-
+
it('should not trigger events that originate within editable elements', function() {
var $outside = $('<input type="text" />').appendTo('body');
e = jQuery.Event('keydown');
@@ -273,12 +273,12 @@ describe('Deck JS', function() {
expect(from).toEqual(1);
expect(to).toEqual(3);
};
-
+
$d.bind('deck.change', f);
$.deck('go', 3);
$d.unbind('deck.change', f);
});
-
+
it('should not change slides if default prevented', function() {
$d.bind('deck.change', false);
$.deck('go', 3);
@@ -286,33 +286,33 @@ describe('Deck JS', function() {
$d.unbind('deck.change', false);
});
});
-
+
describe('deck.init', function() {
it('should fire on deck initialization', function() {
expect('deck.init').toHaveBeenTriggeredOn($d);
});
-
+
it('should have already populated the slides array', function() {
var f = function() {
expect($.deck('getSlides').length).toBeGreaterThan(0);
};
-
+
$d.bind('deck.init', f);
$.deck('.slide');
$d.unbind('deck.init', f);
});
});
-
+
describe('deck.beforeInit', function() {
it('should fire on deck initialization', function() {
expect('deck.beforeInit').toHaveBeenTriggeredOn($d);
});
-
+
it('should have not populated the slides array', function() {
var f = function() {
expect($.deck('getSlides').length).toEqual(0);
};
-
+
$d.bind('deck.beforeInit', f);
$.deck('.slide');
$d.unbind('deck.beforeInit', f);
@@ -320,7 +320,7 @@ describe('Deck JS', function() {
});
});
});
-
+
describe('complex html structure', function() {
beforeEach(function() {
loadFixtures('complex.html');
@@ -341,43 +341,43 @@ describe('Deck JS', function() {
]);
$.deck('go', 2);
});
-
+
describe('compound state classes', function() {
it('should apply current class', function() {
$('.slide3').each(function(i, el) {
expect($(el)).toHaveClass(defaults.classes.current);
});
});
-
+
it('should apply previous class', function() {
$('.slide2').each(function(i, el) {
expect($(el)).toHaveClass(defaults.classes.previous);
});
});
-
+
it('should apply next class', function() {
$('.slide4').each(function(i, el) {
expect($(el)).toHaveClass(defaults.classes.next);
});
});
-
+
it('should apply before class', function() {
$('.slide1').each(function(i, el) {
expect($(el)).toHaveClass(defaults.classes.before);
});
});
-
+
it('should apply after class', function() {
$('.slide5, .slide6, .slide7, .slide8, .slide9, .slide10').each(function(i, el) {
expect($(el)).toHaveClass(defaults.classes.after);
});
});
-
+
it('should apply child-current class', function() {
expect($('.slide2').not('.slide10')).toHaveClass(defaults.classes.childCurrent);
});
});
-
+
it('should remove old state classes', function() {
$.deck('go', 4);
expect($('.slide3').not('.slide5')).not.toHaveClass(defaults.classes.current);
@@ -386,49 +386,12 @@ describe('Deck JS', function() {
});
});
- describe('iframes', function() {
- beforeEach(function() {
- loadFixtures('iframes.html');
- if (Modernizr.history) {
- history.replaceState({}, "", "#")
- }
- $.deck([
- '.slide1',
- '.slide2',
- '.slide3',
- '.slide4',
- '.slide5',
- '.slide6',
- '.slide7',
- '.slide8',
- '.slide9',
- '.slide10',
- ]);
-
- });
-
- it('should remove/restore iframe sources when leaving/entering a slide', function() {
- $.deck('go', 4);
- expect($.deck('getSlide').find('iframe').attr('src')).toEqual('fixtures/iframe_simple.html');
- $.deck('next');
- expect($('.slide5').find('iframe').attr('src')).toEqual('');
- $.deck('prev');
- expect($('.slide5').find('iframe').attr('src')).toEqual('fixtures/iframe_simple.html');
- });
-
- it('should not store blank iframe sources', function() {
- $.deck('go', 6);
- $.deck('next');
- expect($.deck('getSlide').find('iframe').data('src')).toBeUndefined();
- });
- });
-
describe('empty deck', function() {
beforeEach(function() {
loadFixtures('empty.html');
$.deck('.slide');
});
-
+
describe('getSlide()', function() {
it('should not error on init', $.noop);
});
@@ -9,27 +9,27 @@ describe('Deck JS Hash Extension', function() {
}
$.deck('.slide');
});
-
+
it('should assign ids to slides that do not have them', function() {
var slides = $.deck('getSlides');
$.each(slides, function(i, $e) {
expect($e.attr('id')).toBeTruthy();
});
});
-
+
it('should reassign ids on reinitialization', function() {
var $firstSlide = $.deck('getSlide', 0),
firstID = $firstSlide.attr('id');
-
+
$firstSlide.before('<div class="slide"></div>');
$.deck('.slide');
expect($firstSlide).not.toHaveId(firstID);
});
-
+
it('should update container with a state class including the slide id', function() {
var $c = $.deck('getContainer'),
osp = defaults.classes.onPrefix;
-
+
expect($c).toHaveClass(osp + $.deck('getSlide', 0).attr('id'));
$.deck('next');
expect($c).toHaveClass(osp + $.deck('getSlide', 1).attr('id'));
@@ -37,43 +37,45 @@ describe('Deck JS Hash Extension', function() {
expect($c).not.toHaveClass(osp + $.deck('getSlide', 1).attr('id'));
expect($c).toHaveClass(osp + $.deck('getSlide', 2).attr('id'));
});
-
+
it('should update the href on slide change', function() {
var $hashLink = $(defaults.selectors.hashLink);
$.deck('go', 3);
expect($hashLink.attr('href')).toMatch('#slide-3');
});
-
+
it('should use existing ids if they exist', function() {
var $hashLink = $(defaults.selectors.hashLink);
$.deck('go', 1);
expect($hashLink.attr('href')).toMatch('#custom-id');
});
-
+
it('should update the URL on slide change (if supported)', function() {
if (Modernizr.history) {
$.deck('go', 3);
expect(window.location.hash).toEqual('#slide-3');
}
});
-
+
it('should deep link to slide on deck init', function() {
window.location.hash = "#slide-3";
$.deck('.slide');
- expect($.deck('getSlide')).toHaveId('slide-3');
+ waitsFor(function() {
+ return $.deck('getSlide').attr('id') === 'slide-3';
+ });
});
-
+
it('should follow internal hash links using hashchange (if supported)', function() {
if (Modernizr.hashchange) {
window.location.hash = "#slide-3";
-
+
// Hashchange event doesn't fire right when the hash changes?
waitsFor(function() {
return $.deck('getSlide').attr('id') === 'slide-3';
}, 'hash to change to slide-3', 2000);
}
});
-
+
it('should follow internal hash links on click', function() {
/* Triggered clicks dont generate hashchanges, so until I find
a way to do this in an automated fashion, needs to be hand tested. */
@@ -9,18 +9,18 @@ describe('Deck JS Navigation Buttons', function() {
}
$.deck('.slide');
});
-
+
it('should go to the next slide if next link is clicked', function() {
$(defaults.selectors.nextLink).click();
expect($.deck('getSlide')).toHaveClass('slide2');
});
-
+
it('should go to the previous slide if previous link is clicked', function() {
$.deck('go', 2);
$(defaults.selectors.previousLink).click();
expect($.deck('getSlide')).toHaveClass('slide2');
});
-
+
it('should add the disabled class to the previous link if on first slide', function() {
expect($(defaults.selectors.previousLink)).toHaveClass(defaults.classes.navDisabled);
$(defaults.selectors.nextLink).click();
@@ -28,19 +28,21 @@ describe('Deck JS Navigation Buttons', function() {
$(defaults.selectors.previousLink).click();
expect($(defaults.selectors.previousLink)).toHaveClass(defaults.classes.navDisabled);
});
-
+
it('should add the disabled class to the next link if on last slide', function() {
expect($(defaults.selectors.nextLink)).not.toHaveClass(defaults.classes.navDisabled);
$.deck('go', $.deck('getSlides').length - 1);
expect($(defaults.selectors.nextLink)).toHaveClass(defaults.classes.navDisabled);
});
-
+
it('should not start disabled if deck initialized in the middle', function() {
$.deck('go', 2);
$.deck('.slide');
- expect($(defaults.selectors.previousLink)).not.toHaveClass(defaults.classes.navDisabled);
+ waitsFor(function() {
+ return !$(defaults.selectors.previousLink).hasClass(defaults.classes.navDisabled);
+ });
});
-
+
it('should update the links hrefs with real fragment ids', function() {
expect($(defaults.selectors.previousLink).attr('href')).toMatch(/#$/);
expect($(defaults.selectors.nextLink).attr('href')).toMatch('#custom-id');
@@ -9,18 +9,20 @@ describe('Deck JS Status Indicator', function() {
}
$.deck('.slide');
});
-
+
it('should show the correct total number of slides', function() {
expect($(defaults.selectors.statusTotal)).toHaveText($.deck('getSlides').length);
});
-
+
it('should start at the right current slide', function() {
expect($(defaults.selectors.statusCurrent)).toHaveText(1);
$.deck('go', 2);
$.deck('.slide');
- expect($(defaults.selectors.statusCurrent)).toHaveText(3);
+ waitsFor(function() {
+ return $(defaults.selectors.statusCurrent).text() === '3';
+ });
});
-
+
it('should update to the correct number on slide change', function() {
$.deck('go', 2);
expect($(defaults.selectors.statusCurrent)).toHaveText('3');
@@ -40,11 +42,11 @@ describe('countNested false indicator', function() {
countNested: false
});
});
-
+
it('should ignore nested slides in the total', function() {
expect($(defaults.selectors.statusTotal)).toHaveText('5');
});
-
+
it('should update to the root slide number when nested becomes active', function() {
$.deck('go', 10);
expect($(defaults.selectors.statusCurrent)).toHaveText('4');