-
Notifications
You must be signed in to change notification settings - Fork 110
/
expandCollapseAllSpec.js
48 lines (41 loc) · 1.81 KB
/
expandCollapseAllSpec.js
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
import expandCollapseAll from '../utils/expandCollapseAll';
describe('expandCollapseAll test suite', () => {
beforeAll(() => fixture.setBase('app/assets/javascripts/spec/fixtures'));
beforeEach(() => {
$('body').html(fixture.load('accordion.html'));
expandCollapseAll({ selector: '#accordion' });
});
afterEach(() => {
fixture.cleanup();
});
it('should be able to expand all sections when all are either expanded or collapsed', () => {
// Collapse all of the sections
// - click on 'collapse all' should have no effect
// - click on 'expand all' should expand all sections
$('#accordion div.panel-collapse').collapse('hide');
expect($('.in').length === 0);
$('a[data-toggle-direction="hide"]').click();
expect($('.in').length === 0);
$('a[data-toggle-direction="show"]').click();
expect($('.in').length === 3);
// Expand all of the sections
// - click on 'expand all' should have no effect
// - click on 'collapse all' should collapse all sections
$('#accordion div.panel-collapse').collapse('show');
expect($('.in').length === 3);
$('a[data-toggle-direction="show"]').click();
expect($('.in').length === 3);
$('a[data-toggle-direction="hide"]').click();
expect($('.in').length === 0);
});
it('should be able to expand all sections when some are open and some collapsed', () => {
// Expand 2 of the 3 sections - click 'collapse all' - verify that all are collapsed
$('#collapseA, #collapseC').collapse('show');
$('a[data-toggle-direction="hide"]').click();
expect($('.in').length === 0);
// Expand 2 of the 3 sections - click 'expand all' - verify that all are expanded
$('#collapseA, #collapseC').collapse('show');
$('a[data-toggle-direction="show"]').click();
expect($('.in').length === 3);
});
});