Set better initial states in deck.navigation, closes #55
[deck.js.git] / test / spec.navigation.js
blobafdb39d25043219ae2cb93eacb0922d13e5d58b4
1 describe('Deck JS Navigation Buttons', function() {
2 beforeEach(function() {
3 loadFixtures('standard.html');
4 if (Modernizr.history) {
5 history.replaceState({}, "", "#")
7 else {
8 window.location.hash = '#';
10 $.deck('.slide');
11 });
13 it('should go to the next slide if next link is clicked', function() {
14 $(defaults.selectors.nextLink).click();
15 expect($.deck('getSlide')).toHaveClass('slide2');
16 });
18 it('should go to the previous slide if previous link is clicked', function() {
19 $.deck('go', 2);
20 $(defaults.selectors.previousLink).click();
21 expect($.deck('getSlide')).toHaveClass('slide2');
22 });
24 it('should add the disabled class to the previous link if on first slide', function() {
25 expect($(defaults.selectors.previousLink)).toHaveClass(defaults.classes.navDisabled);
26 $(defaults.selectors.nextLink).click();
27 expect($(defaults.selectors.previousLink)).not.toHaveClass(defaults.classes.navDisabled);
28 $(defaults.selectors.previousLink).click();
29 expect($(defaults.selectors.previousLink)).toHaveClass(defaults.classes.navDisabled);
30 });
32 it('should add the disabled class to the next link if on last slide', function() {
33 expect($(defaults.selectors.nextLink)).not.toHaveClass(defaults.classes.navDisabled);
34 $.deck('go', $.deck('getSlides').length - 1);
35 expect($(defaults.selectors.nextLink)).toHaveClass(defaults.classes.navDisabled);
36 });
38 it('should not start disabled if deck initialized in the middle', function() {
39 $.deck('go', 2);
40 $.deck('.slide');
41 expect($(defaults.selectors.previousLink)).not.toHaveClass(defaults.classes.navDisabled);
42 });
44 it('should update the links hrefs with real fragment ids', function() {
45 expect($(defaults.selectors.previousLink)).toHaveAttr('href', '#');
46 expect($(defaults.selectors.nextLink)).toHaveAttr('href', '#custom-id');
47 $.deck('go', 2);
48 expect($(defaults.selectors.previousLink)).toHaveAttr('href', '#custom-id');
49 expect($(defaults.selectors.nextLink)).toHaveAttr('href', '#slide-3');
50 });
51 });