-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathAnchorModifiers.test.js
More file actions
98 lines (87 loc) · 3.83 KB
/
AnchorModifiers.test.js
File metadata and controls
98 lines (87 loc) · 3.83 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
describe('AnchorModifiers jsx', () => {
beforeEach(async () => {
await page.goto('http://localhost:6969/anchor-modifiers')
await page.waitForSelector('[data-hydrated]')
})
test('Clicking html link with shift opens in new window', async () => {
await page.keyboard.down('Shift')
await page.click('[href="/anchor-modifiers?source=html"]')
await page.keyboard.up('Shift')
const url = await page.url()
expect(url).toEqual('http://localhost:6969/anchor-modifiers')
})
test('Clicking html link with control or meta opens in new tab', async () => {
const key = process.platform === 'darwin' ? 'Meta' : 'Control'
await page.keyboard.down(key)
await page.click('[href="/anchor-modifiers?source=html"]')
await page.keyboard.up(key)
const url = await page.url()
expect(url).toEqual('http://localhost:6969/anchor-modifiers')
})
test('Clicking html link with alt downloads the link', async () => {
await page.keyboard.down('Alt')
await page.click('[href="/anchor-modifiers?source=html"]')
await page.keyboard.up('Alt')
const url = await page.url()
expect(url).toEqual('http://localhost:6969/anchor-modifiers')
})
test('Clicking jsx link with shift opens in new window', async () => {
await page.keyboard.down('Shift')
await page.click('[href="/anchor-modifiers?source=jsx"]')
await page.keyboard.up('Shift')
const url = await page.url()
expect(url).toEqual('http://localhost:6969/anchor-modifiers')
})
test('Clicking jsx link with control or meta opens in new tab', async () => {
const key = process.platform === 'darwin' ? 'Meta' : 'Control'
await page.keyboard.down(key)
await page.click('[href="/anchor-modifiers?source=jsx"]')
await page.keyboard.up(key)
const url = await page.url()
expect(url).toEqual('http://localhost:6969/anchor-modifiers')
})
test('Clicking jsx link with alt downloads the link', async () => {
await page.keyboard.down('Alt')
await page.click('[href="/anchor-modifiers?source=jsx"]')
await page.keyboard.up('Alt')
const url = await page.url()
expect(url).toEqual('http://localhost:6969/anchor-modifiers')
})
test('Clicking html link with modifier runs the original event', async () => {
await page.keyboard.down('Shift')
await page.click('[href="/anchor-modifiers?source=html"]')
await page.keyboard.up('Shift')
await page.waitForSelector('[data-clicked-html]')
const element = await page.$('[data-clicked-html]')
expect(element).toBeTruthy()
})
test('Clicking jsx link with modifier runs the original event', async () => {
await page.keyboard.down('Shift')
await page.click('[href="/anchor-modifiers?source=jsx"]')
await page.keyboard.up('Shift')
await page.waitForSelector('[data-clicked-jsx]')
const element = await page.$('[data-clicked-jsx]')
expect(element).toBeTruthy()
})
test('anchors can have events', async () => {
await page.click('button')
await page.click('[href="/anchor-modifiers?source=incremented"]')
await page.waitForSelector('[data-updated] [data-count="1"]')
const element = await page.$('[data-updated] [data-count="1"]')
expect(element).toBeTruthy()
})
test('anchors can have object events', async () => {
await page.click('button')
await page.click('[href="/anchor-modifiers?source=object"]')
await page.waitForSelector('[data-updated] [data-objected]')
const element = await page.$('[data-updated] [data-objected]')
expect(element).toBeTruthy()
})
test('anchors can have array events', async () => {
await page.click('button')
await page.click('[href="/anchor-modifiers?source=array"]')
await page.waitForSelector('[data-updated] [data-count="1"][data-objected]')
const element = await page.$('[data-updated] [data-count="1"][data-objected]')
expect(element).toBeTruthy()
})
})