-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathaccordion.e2e-spec.ts
66 lines (54 loc) · 2 KB
/
accordion.e2e-spec.ts
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
61
62
63
64
65
66
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { browser, element, by, Key } from 'protractor';
import { hasClass } from './e2e-helper';
describe('accordion', () => {
beforeEach(done => {
browser.get('#/accordion/accordion-test.component').then(() => done());
});
it('should display the 4 accordion items', () => {
expect(element.all(by.css('nb-accordion > nb-accordion-item')).count()).toEqual(4);
expect(
element(
by.css('nb-accordion > nb-accordion-item:nth-child(1) > nb-accordion-item-header'),
).getText(),
).toEqual('Accordion #1', 'fist item title');
expect(
element(
by.css('nb-accordion > nb-accordion-item:nth-child(2) > nb-accordion-item-header'),
).getText(),
).toEqual('Accordion #2', 'second item title');
expect(
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(2)')), 'collapsed'),
).toBeTruthy('second is collapsed');
expect(
element(
by.css('nb-accordion > nb-accordion-item:nth-child(3) > nb-accordion-item-header'),
).getText(),
).toEqual('Accordion #3', 'third item title');
expect(
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')), 'expanded'),
).toBeTruthy('second is expanded');
});
describe('a11y', () => {
it('should be interactable through keyboard', () => {
expect(
hasClass(
element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')) , 'expanded',
),
).toBeTruthy();
return element(by.css('nb-accordion > nb-accordion-item:nth-child(3) > nb-accordion-item-header'))
.sendKeys(Key.ENTER)
.then(() => {
expect(
hasClass(
element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')), 'collapsed',
),
).toBeTruthy('nb-accordion-item is collapsed');
})
})
})
});