Skip to content

Commit 1285c2a

Browse files
authored
test: refactor tabs unit tests to not use Lumo entrypoints (#8950)
1 parent c0838ee commit 1285c2a

3 files changed

Lines changed: 73 additions & 7 deletions

File tree

‎packages/tabs/test/scroll.test.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from '@vaadin/chai-plugins';
22
import { arrowDown, arrowLeft, arrowRight, arrowUp, fixtureSync, nextFrame, nextRender } from '@vaadin/testing-helpers';
3-
import './not-animated-styles.js';
4-
import '../vaadin-tabs.js';
3+
import './tabs-test-styles.js';
4+
import '../src/vaadin-tabs.js';
55

66
describe('scrollable tabs', () => {
77
let tabs, items, scroller;
@@ -112,7 +112,7 @@ describe('scrollable tabs', () => {
112112
beforeEach(async () => {
113113
itemsInViewport = new Set();
114114
tabs.setAttribute('dir', dir);
115-
await nextFrame();
115+
await nextRender();
116116
});
117117

118118
it('should have displayed all the items fully when scrolled forward to the end via button', async () => {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2+
3+
// TODO: subset of Lumo needed for unit tests to pass.
4+
// These should be eventually covered by base styles.
5+
registerStyles(
6+
'vaadin-tabs',
7+
css`
8+
::slotted(vaadin-tab) {
9+
display: flex;
10+
box-sizing: border-box;
11+
padding: 0.5rem 0.75rem;
12+
font-family: -apple-system, 'system-ui', Roboto, 'Segoe UI', Helvetica, Arial, sans-serif;
13+
font-size: 16px;
14+
font-weight: 500;
15+
}
16+
17+
::slotted(vaadin-tab[orientation='vertical']) {
18+
padding: 0.25rem 1rem;
19+
}
20+
21+
:host(:not([orientation='vertical'])) {
22+
position: relative;
23+
min-height: 2.75rem;
24+
}
25+
26+
:host([orientation='horizontal']) [part='tabs'] {
27+
margin: 0 0.75rem;
28+
}
29+
30+
[part='forward-button'],
31+
[part='back-button'] {
32+
position: absolute;
33+
z-index: 1;
34+
top: 0;
35+
font-size: 24px;
36+
width: 1.5em;
37+
}
38+
39+
:host(:not([dir='rtl'])) [part='forward-button'] {
40+
right: 0;
41+
}
42+
43+
:host([dir='rtl']) [part='forward-button'] {
44+
left: 0;
45+
}
46+
47+
/* Used by "separator" element in scroll tests */
48+
:host(:not([dir='rtl'])) ::slotted(:not(vaadin-tab)) {
49+
margin-left: 1rem;
50+
}
51+
52+
:host([dir='rtl']) ::slotted(:not(vaadin-tab)) {
53+
margin-right: 1rem;
54+
}
55+
56+
/* Lumo-specific, should it be in base styles? */
57+
:host([theme~='equal-width-tabs']) {
58+
flex: auto;
59+
}
60+
61+
:host([theme~='equal-width-tabs']) [part='tabs'] ::slotted(vaadin-tab) {
62+
flex: 1 0 0%;
63+
}
64+
`,
65+
);

‎packages/tabs/test/tabs.test.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import {
55
enter,
66
fixtureSync,
77
listenOnce,
8-
nextFrame,
98
nextRender,
109
nextResize,
1110
space,
1211
} from '@vaadin/testing-helpers';
1312
import sinon from 'sinon';
14-
import '../vaadin-tabs.js';
13+
import './tabs-test-styles.js';
14+
import '../src/vaadin-tabs.js';
1515

1616
describe('tabs', () => {
1717
let tabs;
@@ -103,7 +103,7 @@ describe('tabs', () => {
103103
tabs.style.height = '100px';
104104
}
105105
await nextResize(tabs);
106-
await nextFrame();
106+
await nextRender();
107107
});
108108

109109
afterEach(() => {
@@ -181,7 +181,7 @@ describe('tabs', () => {
181181

182182
it('should update overflow on items change', async () => {
183183
tabs.items.forEach((item) => item.remove());
184-
await nextFrame();
184+
await nextRender();
185185
expect(tabs.hasAttribute('overflow')).to.be.false;
186186
});
187187
});
@@ -247,6 +247,7 @@ describe('flex child tabs', () => {
247247
});
248248
});
249249

250+
// TODO: should be either covered by base styles or moved to visual tests
250251
describe('flex equal width tabs', () => {
251252
let wrapper, tabs;
252253

0 commit comments

Comments
 (0)