60 lines
No EOL
1.7 KiB
JavaScript
60 lines
No EOL
1.7 KiB
JavaScript
describe('Deck JS Hash Extension', function() {
|
|
beforeEach(function() {
|
|
loadFixtures('standard.html');
|
|
if (Modernizr.history) {
|
|
history.replaceState({}, "", "#")
|
|
}
|
|
else {
|
|
window.location.hash = '#';
|
|
}
|
|
$.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 update the href on slide change', function() {
|
|
var $hashLink = $(defaults.selectors.hashLink);
|
|
$.deck('go', 3);
|
|
expect($hashLink).toHaveAttr('href', '#slide-3');
|
|
});
|
|
|
|
it('should use existing ids if they exist', function() {
|
|
var $hashLink = $(defaults.selectors.hashLink);
|
|
$.deck('go', 1);
|
|
expect($hashLink).toHaveAttr('href', '#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');
|
|
});
|
|
|
|
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. */
|
|
});
|
|
}); |