summaryrefslogtreecommitdiffstats
path: root/doc/backends/deckjs/deck.js/test/spec.status.js
blob: 5232f1c8e87d140506a265b0101f076f2fe6b1de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
describe('Deck JS Status Indicator', function() {
  beforeEach(function() {
    loadFixtures('standard.html');
    if (Modernizr.history) {
      history.replaceState({}, "", "#")
    }
    else {
      window.location.hash = '#';
    }
    $.deck('.slide');
  });

  it('should show the correct total number of slides', function() {
    expect($(defaults.selectors.statusTotal)).toHaveText($.deck('getSlides').length);
  });

  it('should start at the right current slide', function() {
    expect($(defaults.selectors.statusCurrent)).toHaveText(1);
    $.deck('go', 2);
    $.deck('.slide');
    waitsFor(function() {
      return $(defaults.selectors.statusCurrent).text() === '3';
    });
  });

  it('should update to the correct number on slide change', function() {
    $.deck('go', 2);
    expect($(defaults.selectors.statusCurrent)).toHaveText('3');
  });
});

describe('countNested false indicator', function() {
  beforeEach(function() {
    loadFixtures('nesteds.html');
    if (Modernizr.history) {
      history.replaceState({}, "", "#")
    }
    else {
      window.location.hash = '#';
    }
    $.deck('.slide', {
      countNested: false
    });
  });

  it('should ignore nested slides in the total', function() {
    expect($(defaults.selectors.statusTotal)).toHaveText('5');
  });

  it('should update to the root slide number when nested becomes active', function() {
    $.deck('go', 10);
    expect($(defaults.selectors.statusCurrent)).toHaveText('4');
    $.deck('prev');
    expect($(defaults.selectors.statusCurrent)).toHaveText('3');
    $.deck('go', 3);
    expect($(defaults.selectors.statusCurrent)).toHaveText('3');
    $.deck('go', 1);
    expect($(defaults.selectors.statusCurrent)).toHaveText('2');
  });
});