Skip to content

Commit 08e5d1e

Browse files
Clean up tests for removed iframe hack and deferred hash goto call
1 parent df65f55 commit 08e5d1e

File tree

6 files changed

+53
-126
lines changed

6 files changed

+53
-126
lines changed

test/fixtures/iframe_simple.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/fixtures/iframes.html

Lines changed: 0 additions & 32 deletions
This file was deleted.

test/spec.core.js

Lines changed: 21 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('Deck JS', function() {
5151
$.deck('go', 5);
5252
expect($.deck('getSlide')).toHaveClass('slide1');
5353
});
54-
54+
5555
it('should go nowhere if id does not exist', function() {
5656
$.deck('go', 'i-dont-exist');
5757
expect($.deck('getSlide')).toHaveClass('slide1');
@@ -123,13 +123,13 @@ describe('Deck JS', function() {
123123
expect(slides).toEqual(expectation);
124124
});
125125
});
126-
126+
127127
describe('getContainer()', function() {
128128
it('should return a jQuery object with the container element(s)', function() {
129129
expect($.deck('getContainer')).toBe(defaults.selectors.container);
130130
});
131131
});
132-
132+
133133
describe('getOptions()', function() {
134134
it('should return the current options object', function() {
135135
expect($.deck('getOptions')).toEqual(defaults);
@@ -229,7 +229,7 @@ describe('Deck JS', function() {
229229
$d.trigger(e);
230230
expect($.deck('getSlide')).toHaveClass('alt-slide1');
231231
});
232-
232+
233233
it('should not trigger events that originate within editable elements', function() {
234234
var $outside = $('<input type="text" />').appendTo('body');
235235
e = jQuery.Event('keydown');
@@ -273,54 +273,54 @@ describe('Deck JS', function() {
273273
expect(from).toEqual(1);
274274
expect(to).toEqual(3);
275275
};
276-
276+
277277
$d.bind('deck.change', f);
278278
$.deck('go', 3);
279279
$d.unbind('deck.change', f);
280280
});
281-
281+
282282
it('should not change slides if default prevented', function() {
283283
$d.bind('deck.change', false);
284284
$.deck('go', 3);
285285
expect($.deck('getSlide')).toEqual($.deck('getSlide', 1));
286286
$d.unbind('deck.change', false);
287287
});
288288
});
289-
289+
290290
describe('deck.init', function() {
291291
it('should fire on deck initialization', function() {
292292
expect('deck.init').toHaveBeenTriggeredOn($d);
293293
});
294-
294+
295295
it('should have already populated the slides array', function() {
296296
var f = function() {
297297
expect($.deck('getSlides').length).toBeGreaterThan(0);
298298
};
299-
299+
300300
$d.bind('deck.init', f);
301301
$.deck('.slide');
302302
$d.unbind('deck.init', f);
303303
});
304304
});
305-
305+
306306
describe('deck.beforeInit', function() {
307307
it('should fire on deck initialization', function() {
308308
expect('deck.beforeInit').toHaveBeenTriggeredOn($d);
309309
});
310-
310+
311311
it('should have not populated the slides array', function() {
312312
var f = function() {
313313
expect($.deck('getSlides').length).toEqual(0);
314314
};
315-
315+
316316
$d.bind('deck.beforeInit', f);
317317
$.deck('.slide');
318318
$d.unbind('deck.beforeInit', f);
319319
});
320320
});
321321
});
322322
});
323-
323+
324324
describe('complex html structure', function() {
325325
beforeEach(function() {
326326
loadFixtures('complex.html');
@@ -341,43 +341,43 @@ describe('Deck JS', function() {
341341
]);
342342
$.deck('go', 2);
343343
});
344-
344+
345345
describe('compound state classes', function() {
346346
it('should apply current class', function() {
347347
$('.slide3').each(function(i, el) {
348348
expect($(el)).toHaveClass(defaults.classes.current);
349349
});
350350
});
351-
351+
352352
it('should apply previous class', function() {
353353
$('.slide2').each(function(i, el) {
354354
expect($(el)).toHaveClass(defaults.classes.previous);
355355
});
356356
});
357-
357+
358358
it('should apply next class', function() {
359359
$('.slide4').each(function(i, el) {
360360
expect($(el)).toHaveClass(defaults.classes.next);
361361
});
362362
});
363-
363+
364364
it('should apply before class', function() {
365365
$('.slide1').each(function(i, el) {
366366
expect($(el)).toHaveClass(defaults.classes.before);
367367
});
368368
});
369-
369+
370370
it('should apply after class', function() {
371371
$('.slide5, .slide6, .slide7, .slide8, .slide9, .slide10').each(function(i, el) {
372372
expect($(el)).toHaveClass(defaults.classes.after);
373373
});
374374
});
375-
375+
376376
it('should apply child-current class', function() {
377377
expect($('.slide2').not('.slide10')).toHaveClass(defaults.classes.childCurrent);
378378
});
379379
});
380-
380+
381381
it('should remove old state classes', function() {
382382
$.deck('go', 4);
383383
expect($('.slide3').not('.slide5')).not.toHaveClass(defaults.classes.current);
@@ -386,49 +386,12 @@ describe('Deck JS', function() {
386386
});
387387
});
388388

389-
describe('iframes', function() {
390-
beforeEach(function() {
391-
loadFixtures('iframes.html');
392-
if (Modernizr.history) {
393-
history.replaceState({}, "", "#")
394-
}
395-
$.deck([
396-
'.slide1',
397-
'.slide2',
398-
'.slide3',
399-
'.slide4',
400-
'.slide5',
401-
'.slide6',
402-
'.slide7',
403-
'.slide8',
404-
'.slide9',
405-
'.slide10',
406-
]);
407-
408-
});
409-
410-
it('should remove/restore iframe sources when leaving/entering a slide', function() {
411-
$.deck('go', 4);
412-
expect($.deck('getSlide').find('iframe').attr('src')).toEqual('fixtures/iframe_simple.html');
413-
$.deck('next');
414-
expect($('.slide5').find('iframe').attr('src')).toEqual('');
415-
$.deck('prev');
416-
expect($('.slide5').find('iframe').attr('src')).toEqual('fixtures/iframe_simple.html');
417-
});
418-
419-
it('should not store blank iframe sources', function() {
420-
$.deck('go', 6);
421-
$.deck('next');
422-
expect($.deck('getSlide').find('iframe').data('src')).toBeUndefined();
423-
});
424-
});
425-
426389
describe('empty deck', function() {
427390
beforeEach(function() {
428391
loadFixtures('empty.html');
429392
$.deck('.slide');
430393
});
431-
394+
432395
describe('getSlide()', function() {
433396
it('should not error on init', $.noop);
434397
});

test/spec.hash.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,71 +9,73 @@ describe('Deck JS Hash Extension', function() {
99
}
1010
$.deck('.slide');
1111
});
12-
12+
1313
it('should assign ids to slides that do not have them', function() {
1414
var slides = $.deck('getSlides');
1515
$.each(slides, function(i, $e) {
1616
expect($e.attr('id')).toBeTruthy();
1717
});
1818
});
19-
19+
2020
it('should reassign ids on reinitialization', function() {
2121
var $firstSlide = $.deck('getSlide', 0),
2222
firstID = $firstSlide.attr('id');
23-
23+
2424
$firstSlide.before('<div class="slide"></div>');
2525
$.deck('.slide');
2626
expect($firstSlide).not.toHaveId(firstID);
2727
});
28-
28+
2929
it('should update container with a state class including the slide id', function() {
3030
var $c = $.deck('getContainer'),
3131
osp = defaults.classes.onPrefix;
32-
32+
3333
expect($c).toHaveClass(osp + $.deck('getSlide', 0).attr('id'));
3434
$.deck('next');
3535
expect($c).toHaveClass(osp + $.deck('getSlide', 1).attr('id'));
3636
$.deck('next');
3737
expect($c).not.toHaveClass(osp + $.deck('getSlide', 1).attr('id'));
3838
expect($c).toHaveClass(osp + $.deck('getSlide', 2).attr('id'));
3939
});
40-
40+
4141
it('should update the href on slide change', function() {
4242
var $hashLink = $(defaults.selectors.hashLink);
4343
$.deck('go', 3);
4444
expect($hashLink.attr('href')).toMatch('#slide-3');
4545
});
46-
46+
4747
it('should use existing ids if they exist', function() {
4848
var $hashLink = $(defaults.selectors.hashLink);
4949
$.deck('go', 1);
5050
expect($hashLink.attr('href')).toMatch('#custom-id');
5151
});
52-
52+
5353
it('should update the URL on slide change (if supported)', function() {
5454
if (Modernizr.history) {
5555
$.deck('go', 3);
5656
expect(window.location.hash).toEqual('#slide-3');
5757
}
5858
});
59-
59+
6060
it('should deep link to slide on deck init', function() {
6161
window.location.hash = "#slide-3";
6262
$.deck('.slide');
63-
expect($.deck('getSlide')).toHaveId('slide-3');
63+
waitsFor(function() {
64+
return $.deck('getSlide').attr('id') === 'slide-3';
65+
});
6466
});
65-
67+
6668
it('should follow internal hash links using hashchange (if supported)', function() {
6769
if (Modernizr.hashchange) {
6870
window.location.hash = "#slide-3";
69-
71+
7072
// Hashchange event doesn't fire right when the hash changes?
7173
waitsFor(function() {
7274
return $.deck('getSlide').attr('id') === 'slide-3';
7375
}, 'hash to change to slide-3', 2000);
7476
}
7577
});
76-
78+
7779
it('should follow internal hash links on click', function() {
7880
/* Triggered clicks dont generate hashchanges, so until I find
7981
a way to do this in an automated fashion, needs to be hand tested. */

test/spec.navigation.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,40 @@ describe('Deck JS Navigation Buttons', function() {
99
}
1010
$.deck('.slide');
1111
});
12-
12+
1313
it('should go to the next slide if next link is clicked', function() {
1414
$(defaults.selectors.nextLink).click();
1515
expect($.deck('getSlide')).toHaveClass('slide2');
1616
});
17-
17+
1818
it('should go to the previous slide if previous link is clicked', function() {
1919
$.deck('go', 2);
2020
$(defaults.selectors.previousLink).click();
2121
expect($.deck('getSlide')).toHaveClass('slide2');
2222
});
23-
23+
2424
it('should add the disabled class to the previous link if on first slide', function() {
2525
expect($(defaults.selectors.previousLink)).toHaveClass(defaults.classes.navDisabled);
2626
$(defaults.selectors.nextLink).click();
2727
expect($(defaults.selectors.previousLink)).not.toHaveClass(defaults.classes.navDisabled);
2828
$(defaults.selectors.previousLink).click();
2929
expect($(defaults.selectors.previousLink)).toHaveClass(defaults.classes.navDisabled);
3030
});
31-
31+
3232
it('should add the disabled class to the next link if on last slide', function() {
3333
expect($(defaults.selectors.nextLink)).not.toHaveClass(defaults.classes.navDisabled);
3434
$.deck('go', $.deck('getSlides').length - 1);
3535
expect($(defaults.selectors.nextLink)).toHaveClass(defaults.classes.navDisabled);
3636
});
37-
37+
3838
it('should not start disabled if deck initialized in the middle', function() {
3939
$.deck('go', 2);
4040
$.deck('.slide');
41-
expect($(defaults.selectors.previousLink)).not.toHaveClass(defaults.classes.navDisabled);
41+
waitsFor(function() {
42+
return !$(defaults.selectors.previousLink).hasClass(defaults.classes.navDisabled);
43+
});
4244
});
43-
45+
4446
it('should update the links hrefs with real fragment ids', function() {
4547
expect($(defaults.selectors.previousLink).attr('href')).toMatch(/#$/);
4648
expect($(defaults.selectors.nextLink).attr('href')).toMatch('#custom-id');

0 commit comments

Comments
 (0)