forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdivider.spec.ts
More file actions
108 lines (78 loc) · 3.62 KB
/
divider.spec.ts
File metadata and controls
108 lines (78 loc) · 3.62 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { expect, test } from '../../test/playwright/index.js';
import type { Divider } from './divider.js';
import { DividerAlignContent, DividerAppearance, DividerOrientation, DividerRole } from './divider.options.js';
test.describe('Divider', () => {
test.use({ tagName: 'fluent-divider' });
test('should create with document.createElement()', async ({ page, fastPage }) => {
await fastPage.setTemplate();
let hasError = false;
page.on('pageerror', () => {
hasError = true;
});
await page.evaluate(() => {
document.createElement('fluent-divider');
});
expect(hasError).toBe(false);
});
test('should set a default `role` attribute of "separator"', async ({ fastPage }) => {
const { element } = fastPage;
await expect(element).toHaveJSProperty('elementInternals.role', 'separator');
});
test('should set the internal `role` property to match the `role` attribute', async ({ fastPage }) => {
const { element } = fastPage;
for (const role of Object.values(DividerRole)) {
await test.step(`role="${role}"`, async () => {
await fastPage.setTemplate({ attributes: { role } });
await expect(element).toHaveJSProperty('elementInternals.role', role);
});
}
});
test('should set the `aria-orientation` attribute equal to the `orientation` value', async ({ fastPage }) => {
const { element } = fastPage;
for (const orientation of Object.values(DividerOrientation)) {
await test.step(`orientation="${orientation}"`, async () => {
await fastPage.setTemplate({ attributes: { orientation } });
await expect(element).toHaveJSProperty('elementInternals.ariaOrientation', orientation);
});
}
});
test('should NOT set the `aria-orientation` property when the `role` is "presentation"', async ({ fastPage }) => {
const { element } = fastPage;
await fastPage.setTemplate({ attributes: { orientation: 'vertical' } });
await expect(element).toHaveJSProperty('elementInternals.ariaOrientation', 'vertical');
await element.evaluate((node: Divider) => {
node.role = 'presentation';
});
await expect(element).not.toHaveJSProperty('elementInternals.ariaOrientation', 'vertical');
await expect(element).not.toHaveJSProperty('elementInternals.ariaOrientation', 'horizontal');
});
test('should set the orientation property to match the `orientation` attribute when provided', async ({
fastPage,
}) => {
const { element } = fastPage;
await fastPage.setTemplate({ attributes: { orientation: 'vertical' } });
await element.evaluate((node: Divider) => {
node.orientation = 'horizontal';
});
await expect(element).toHaveJSProperty('orientation', 'horizontal');
});
test('should initialize to the provided value attribute if set post-connection', async ({ fastPage }) => {
const { element } = fastPage;
for (const alignment of Object.values(DividerAlignContent)) {
await test.step(`alignContent="${alignment}"`, async () => {
await fastPage.setTemplate({ attributes: { 'align-content': alignment } });
await expect(element).toHaveJSProperty('alignContent', alignment);
});
}
for (const appearance of Object.values(DividerAppearance)) {
await test.step(`appearance="${appearance}"`, async () => {
await fastPage.setTemplate({ attributes: { appearance } });
await expect(element).toHaveJSProperty('appearance', appearance);
});
}
await test.step('inset', async () => {
await fastPage.setTemplate({ attributes: { inset: true } });
await expect(element).toHaveJSProperty('inset', true);
});
});
});