diff options
author | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-11-07 10:36:10 +0200 |
---|---|---|
committer | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-11-07 10:36:10 +0200 |
commit | 93dc74335a8082e0f54b1da7f6fc6e43ff3c10ee (patch) | |
tree | 3befab98de04fdbb63807c6db1844028ae50d8b6 /doc/backends/deckjs/deck.js/test/spec.navigation.js | |
parent | bdd1dea5e21a00b6af1b0ded09e7d528485d5196 (diff) | |
parent | 5925379b5fb30e548f1ba4e804af9865de8903ae (diff) |
Add 'doc/' from commit '5925379b5fb30e548f1ba4e804af9865de8903ae'
git-subtree-dir: doc
git-subtree-mainline: bdd1dea5e21a00b6af1b0ded09e7d528485d5196
git-subtree-split: 5925379b5fb30e548f1ba4e804af9865de8903ae
Diffstat (limited to 'doc/backends/deckjs/deck.js/test/spec.navigation.js')
-rw-r--r-- | doc/backends/deckjs/deck.js/test/spec.navigation.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/doc/backends/deckjs/deck.js/test/spec.navigation.js b/doc/backends/deckjs/deck.js/test/spec.navigation.js new file mode 100644 index 00000000..db04794a --- /dev/null +++ b/doc/backends/deckjs/deck.js/test/spec.navigation.js @@ -0,0 +1,63 @@ +describe('Deck JS Navigation Buttons', function() { + beforeEach(function() { + loadFixtures('standard.html'); + if (Modernizr.history) { + history.replaceState({}, "", "#") + } + else { + window.location.hash = '#'; + } + $.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(); + expect($(defaults.selectors.previousLink)).not.toHaveClass(defaults.classes.navDisabled); + $(defaults.selectors.previousLink).click(); + expect($(defaults.selectors.previousLink)).toHaveClass(defaults.classes.navDisabled); + }); + + it('should add aria-disabled to previous link if on first slide', function() { + $.deck('go', 0); + expect($(defaults.selectors.previousLink)).toHaveAttr('aria-disabled', 'true'); + }); + + 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 add aria-disabled to next link if on last slide', function() { + $.deck('go', $.deck('getSlides').length - 1); + expect($(defaults.selectors.nextLink)).toHaveAttr('aria-disabled', 'true'); + }); + + it('should not start disabled if deck initialized in the middle', function() { + $.deck('go', 2); + $.deck('.slide'); + 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'); + $.deck('go', 2); + expect($(defaults.selectors.previousLink).attr('href')).toMatch('#custom-id'); + expect($(defaults.selectors.nextLink).attr('href')).toMatch('#slide-3'); + }); +}); |