forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefine-class-fields.test.ts
More file actions
80 lines (74 loc) · 2.21 KB
/
define-class-fields.test.ts
File metadata and controls
80 lines (74 loc) · 2.21 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
import { join } from 'path'
import webdriver from 'next-webdriver'
import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils'
createNextDescribe(
'useDefineForClassFields SWC option',
{
files: join(__dirname, 'fixture'),
dependencies: {
mobx: '6.3.7',
typescript: 'latest',
'@types/react': 'latest',
'@types/node': 'latest',
'mobx-react': '7.2.1',
},
},
({ next }) => {
it('tsx should compile with useDefineForClassFields enabled', async () => {
let browser
try {
browser = await webdriver(next.url, '/')
await browser.elementByCss('#action').click()
await check(
() => browser.elementByCss('#name').text(),
/this is my name: next/
)
} finally {
if (browser) {
await browser.close()
}
}
})
it("Initializes resident to undefined after the call to 'super()' when with useDefineForClassFields enabled", async () => {
let browser
try {
browser = await webdriver(next.url, '/animal')
expect(await browser.elementByCss('#dog').text()).toBe('')
expect(await browser.elementByCss('#dogDecl').text()).toBe('dog')
} finally {
if (browser) {
await browser.close()
}
}
})
async function matchLogs$(browser) {
let data_foundLog = false
let name_foundLog = false
const browserLogs = await browser.log('browser')
browserLogs.forEach((log) => {
if (log.message.includes('data changed')) {
data_foundLog = true
}
if (log.message.includes('name changed')) {
name_foundLog = true
}
})
return [data_foundLog, name_foundLog]
}
it('set accessors from base classes won’t get triggered with useDefineForClassFields enabled', async () => {
let browser
try {
browser = await webdriver(next.url, '/derived')
await matchLogs$(browser).then(([data_foundLog, name_foundLog]) => {
expect(data_foundLog).toBe(true)
expect(name_foundLog).toBe(false)
})
} finally {
if (browser) {
await browser.close()
}
}
})
}
)