Fix current status number on mid-deck init, closes #56
[deck.js.git] / test / spec.status.js
blobfe0e0153c607d9ee8d7eac194489e1d4984b7c99
1 describe('Deck JS Status Indicator', function() {
2         beforeEach(function() {
3                 loadFixtures('standard.html');
4                 if (Modernizr.history) {
5                         history.replaceState({}, "", "#")
6                 }
7                 else {
8                         window.location.hash = '#';
9                 }
10                 $.deck('.slide');
11         });
12         
13         it('should show the correct total number of slides', function() {
14                 expect($(defaults.selectors.statusTotal)).toHaveText($.deck('getSlides').length);
15         });
16         
17         it('should start at the right current slide', function() {
18                 expect($(defaults.selectors.statusCurrent)).toHaveText(1);
19                 $.deck('go', 2);
20                 $.deck('.slide');
21                 expect($(defaults.selectors.statusCurrent)).toHaveText(3);
22         });
23         
24         it('should update to the correct number on slide change', function() {
25                 $.deck('go', 2);
26                 expect($(defaults.selectors.statusCurrent)).toHaveText('3');
27         });
28 });
30 describe('countNested false indicator', function() {
31         beforeEach(function() {
32                 loadFixtures('nesteds.html');
33                 if (Modernizr.history) {
34                         history.replaceState({}, "", "#")
35                 }
36                 else {
37                         window.location.hash = '#';
38                 }
39                 $.deck('.slide', {
40                         countNested: false
41                 });
42         });
43         
44         it('should ignore nested slides in the total', function() {
45                 expect($(defaults.selectors.statusTotal)).toHaveText('5');
46         });
47         
48         it('should update to the root slide number when nested becomes active', function() {
49                 $.deck('go', 10);
50                 expect($(defaults.selectors.statusCurrent)).toHaveText('4');
51                 $.deck('prev');
52                 expect($(defaults.selectors.statusCurrent)).toHaveText('3');
53                 $.deck('go', 3);
54                 expect($(defaults.selectors.statusCurrent)).toHaveText('3');
55                 $.deck('go', 1);
56                 expect($(defaults.selectors.statusCurrent)).toHaveText('2');
57         });
58 });