-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathuui-scroll-container.test.ts
137 lines (122 loc) · 3.55 KB
/
uui-scroll-container.test.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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import { html, fixture, expect, elementUpdated } from '@open-wc/testing';
import { UUIScrollContainerElement } from './uui-scroll-container.element';
import '.';
describe('UUIScrollContainerElement', () => {
let element: UUIScrollContainerElement;
beforeEach(async () => {
element = await fixture(
html`<uui-scroll-container style="width:200px; height:200px;">
1 line<br />
2 line<br />
3 line<br />
4 line<br />
5 line<br />
6 line<br />
7 line<br />
8 line<br />
9 line<br />
10 line<br />
11 line<br />
12 line<br />
13 line<br />
14 line<br />
15 line<br />
16 line<br />
17 line<br />
18 line<br />
19 line<br />
20 line
</uui-scroll-container>`,
);
});
it('passes the a11y audit', async () => {
await expect(element).shadowDom.to.be.accessible();
});
it('can scroll', async () => {
element.scrollTop = 42;
await expect(element.scrollTop).to.be.equal(42);
});
});
describe('UUIScrollContainerElement with a lot of content', () => {
let element: UUIScrollContainerElement;
beforeEach(async () => {
element = await fixture(
html`<uui-scroll-container style="width:200px; height:200px;">
initial line is way toooo long
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY<br />
1 line<br />
2 line<br />
3 line<br />
4 line<br />
5 line<br />
6 line<br />
7 line<br />
8 line<br />
9 line<br />
10 line<br />
11 line<br />
12 line<br />
13 line<br />
14 line<br />
15 line<br />
16 line<br />
17 line<br />
18 line<br />
19 line<br />
20 line
</uui-scroll-container>`,
);
});
it('can scroll', async () => {
element.scrollTop = 42;
await expect(element.scrollTop).to.be.equal(42);
});
it('cant scroll to far', async () => {
element.scrollTop = 9999;
await expect(element.scrollTop).not.to.be.equal(9999);
});
it('cant scroll to less than zero', async () => {
element.scrollTop = -100;
await expect(element.scrollTop).to.be.equal(0);
});
it('can scroll sideways if content enforces it', async () => {
element.scrollLeft = 42;
await expect(element.scrollLeft).to.be.equal(42);
});
});
describe('UUIScrollContainerElement with very little content', () => {
let element: UUIScrollContainerElement;
beforeEach(async () => {
element = await fixture(
html`<uui-scroll-container style="width:200px; height:200px;">
very little content.
</uui-scroll-container>`,
);
});
it('cannot scroll', async () => {
element.scrollTop = 10;
await expect(element.scrollTop).to.be.equal(0);
});
it('cannot scroll sideways', async () => {
element.scrollLeft = 42;
await expect(element.scrollLeft).to.be.equal(0);
});
});
describe('properties', () => {
let element: UUIScrollContainerElement;
beforeEach(async () => {
element = await fixture(
html`<uui-scroll-container style="width:200px; height:200px;">
Hello tests
</uui-scroll-container>`,
);
});
it('has a enforce-scroll property', () => {
expect(element).to.have.property('enforceScroll');
});
it('enforceScroll property set', async () => {
element.enforceScroll = true;
await elementUpdated(element);
expect(element.enforceScroll).to.be.true;
});
});