-
-
Notifications
You must be signed in to change notification settings - Fork 5k
/
Copy pathrouter-link.js
47 lines (40 loc) · 2.02 KB
/
router-link.js
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
// This test should be done in a unit test once we migrate to jest
module.exports = {
'router link': function (browser) {
browser
.url('http://localhost:8080/router-link/')
.waitForElementVisible('#app', 1000)
// assert correct href with base
.assert.cssClassPresent('li:nth-child(1) a', 'custom-class')
.assert.cssClassPresent('li:nth-child(1) a', 'otherClass')
.assert.cssClassPresent('li:nth-child(1) a', 'router-link-active')
.assert.containsText('li:nth-child(2) button', 'N CustomLink')
.assert.attributeContains('li:nth-child(3) a', 'style', 'color:')
.assert.attributeContains('li:nth-child(3) a', 'style', 'font-size: 8px')
.click('li:nth-child(5) a')
.assert.attributeContains('li:nth-child(7) a', 'href', '/router-link/sub/1/nested1')
.assert.attributeContains('li:nth-child(8) a', 'href', '/router-link/sub/1/nested2')
.click('li:nth-child(6) a')
.assert.attributeContains('li:nth-child(7) a', 'href', '/router-link/sub/2/nested1')
.assert.attributeContains('li:nth-child(8) a', 'href', '/router-link/sub/2/nested2')
browser.expect.element('li:nth-child(2) button').to.have.attribute('disabled')
browser.end()
function assertActiveLinks (n, activeA, activeLI, exactActiveA, exactActiveLI) {
browser.click(`li:nth-child(${n}) a`)
activeA.forEach(i => {
browser.assert.cssClassPresent(`li:nth-child(${i}) a`, 'router-link-active')
})
activeLI && activeLI.forEach(i => {
browser.assert.cssClassPresent(`li:nth-child(${i})`, 'router-link-active')
})
exactActiveA.forEach(i => {
browser.assert.cssClassPresent(`li:nth-child(${i}) a`, 'router-link-exact-active')
.assert.cssClassPresent(`li:nth-child(${i}) a`, 'router-link-active')
})
exactActiveLI && exactActiveLI.forEach(i => {
browser.assert.cssClassPresent(`li:nth-child(${i})`, 'router-link-exact-active')
.assert.cssClassPresent(`li:nth-child(${i})`, 'router-link-active')
})
}
}
}