-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathalert.e2e-spec.ts
75 lines (61 loc) · 1.96 KB
/
alert.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
70
71
72
73
74
75
/**
* @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 } from 'protractor';
import { colors, alertSizes as sizes } from './component-shared';
import { waitFor } from './e2e-helper';
let alerts: any[] = [];
function prepareAlerts() {
const result: any[] = [];
let elementNumber: number = 1;
for (const { colorKey, color } of colors) {
for (const { sizeKey, height } of sizes) {
result.push({
size: sizeKey,
height: height,
colorKey,
color,
elementNumber,
});
elementNumber++;
}
}
return result;
}
function prepareAccentAlerts(regularCardsOffset) {
function generateAccentAlerts(accentCardsOffset, colorKey, color) {
return colors.map((c, i) => ({
name: colorKey,
colorKey,
color,
accentColor: c.color,
accentKey: c.colorKey,
elementNumber: regularCardsOffset + accentCardsOffset + i,
}));
}
return colors.reduce((accentCards, { colorKey, color }) => {
return accentCards.concat(generateAccentAlerts(accentCards.length, colorKey, color));
}, []);
}
describe('nb-alert', () => {
alerts = prepareAlerts();
beforeAll((done) => {
browser.get('#/alert/alert-test.component').then(() => done());
});
alerts.forEach(c => {
it(`should display ${c.colorKey} alert with ${c.size} size`, () => {
waitFor(`nb-alert:nth-child(${c.elementNumber})`);
expect(element(by.css(`nb-alert:nth-child(${c.elementNumber})`))
.getText()).toContain('Success message!');
element(by.css(`nb-alert:nth-child(${c.elementNumber})`)).getCssValue('height').then(height => {
expect(height).toEqual(c.height);
});
element(by.css(`nb-alert:nth-child(${c.elementNumber})`))
.getCssValue('background-color').then(bgColor => {
expect(bgColor).toEqual(c.color);
});
});
});
});