forked from ng-bootstrap/ng-bootstrap
/
timepicker-filter.e2e-spec.ts
69 lines (48 loc) · 1.86 KB
/
timepicker-filter.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
67
68
69
import {protractor} from 'protractor';
import {openUrl} from '../../tools.po';
import {TimepickerFilterPage} from './timepicker-filter.po';
describe('Timepicker', () => {
let page: TimepickerFilterPage;
beforeAll(() => page = new TimepickerFilterPage());
beforeEach(async() => await openUrl('timepicker/filter'));
async function expectValue(expectedValue) {
const inputs = page.getFields();
const values = [];
for (let i = 0; i < inputs.length; i++) {
values[i] = await inputs[i].getAttribute('value');
}
expect(values.join(':')).toBe(expectedValue);
}
describe('filter', async() => {
it(`should accept numbers`, async() => {
await expectValue('::'); // No starting values
const inputs = page.getFields();
await inputs[0].sendKeys('1');
await inputs[1].sendKeys('2');
await inputs[2].sendKeys('3');
await inputs[0].click();
await expectValue('01:02:03');
});
it(`shouldn't accept alpha`, async() => {
await expectValue('::'); // No starting values
const inputs = page.getFields();
await inputs[0].sendKeys('A');
await inputs[1].sendKeys('A');
await inputs[2].sendKeys('A');
await inputs[0].click();
await expectValue('::');
});
it(`shouldn accept special commands`, async() => {
const inputs = page.getFields();
await inputs[0].sendKeys('1');
await inputs[0].sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));
await inputs[0].sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'c'));
await inputs[1].click();
await inputs[1].sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'v'));
await inputs[2].click();
await inputs[2].sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'v'));
await inputs[0].click();
await expectValue('01:01:01');
});
});
});