-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
Copy pathnext-dynamic-css.test.ts
75 lines (66 loc) · 2.39 KB
/
next-dynamic-css.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
import { nextTestSetup } from 'e2e-utils'
describe('next-dynamic-css', () => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
})
it('should have correct order of styles between global and css modules', async () => {
const browser = await next.browser('/page')
expect(await browser.waitForElementByCss('#server').text()).toBe(
'Hello Server'
)
expect(
await browser.elementByCss('#server').getComputedCss('background-color')
).toBe('rgb(0, 128, 0)')
expect(await browser.elementByCss('#server').getComputedCss('color')).toBe(
'rgb(0, 0, 0)'
)
})
if (isNextDev) {
// TODO Fix order of styling in development
it.todo(
'should have correct order of styles on client component that is sharing styles with next/dynamic (TODO)'
)
} else {
it('should have correct order of styles on client component that is sharing styles with next/dynamic', async () => {
const browser = await next.browser('/page')
expect(await browser.waitForElementByCss('#inner2').text()).toBe(
'Hello Inner 2'
)
expect(
await browser.elementByCss('#inner2').getComputedCss('background-color')
).toBe('rgb(0, 128, 0)')
expect(
await browser.elementByCss('#inner2').getComputedCss('color')
).toBe('rgb(0, 0, 0)')
})
}
it('should have correct order of styles on next/dynamic loaded component', async () => {
const browser = await next.browser('/page')
expect(await browser.waitForElementByCss('#component').text()).toBe(
'Hello Component'
)
expect(
await browser
.elementByCss('#component')
.getComputedCss('background-color')
).toBe('rgb(0, 128, 0)')
expect(
await browser.elementByCss('#component').getComputedCss('color')
).toBe('rgb(0, 0, 0)')
})
it('should have correct order of global styles between layout and pages', async () => {
const browser = await next.browser('/page')
expect(await browser.waitForElementByCss('#global').text()).toBe(
'Hello Global'
)
expect(
await browser.elementByCss('#global').getComputedCss('background-color')
).toBe('rgba(0, 0, 0, 0)')
expect(await browser.elementByCss('#global').getComputedCss('color')).toBe(
'rgb(0, 0, 0)'
)
expect(
await browser.elementByCss('body').getComputedCss('background-color')
).toBe('rgb(255, 255, 255)')
})
})