Skip to content

Commit 3f96e51

Browse files
committed
test: update tests to search for the <nav> element
1 parent 47b7dda commit 3f96e51

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/@vue/cli-plugin-router/__tests__/routerGenerator.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test('base', async () => {
1313
expect(files['src/views/HomeView.vue']).toBeTruthy()
1414
expect(files['src/App.vue']).toMatch('<router-link to="/">Home</router-link>')
1515
expect(files['src/App.vue']).not.toMatch('<script>')
16-
expect(files['src/App.vue']).toMatch('#nav a.router-link-exact-active')
16+
expect(files['src/App.vue']).toMatch('nav a.router-link-exact-active')
1717

1818
expect(pkg.dependencies).toHaveProperty('vue-router')
1919
})
@@ -33,7 +33,7 @@ test('history mode', async () => {
3333
expect(files['src/views/HomeView.vue']).toBeTruthy()
3434
expect(files['src/App.vue']).toMatch('<router-link to="/">Home</router-link>')
3535
expect(files['src/App.vue']).not.toMatch('<script>')
36-
expect(files['src/App.vue']).toMatch('#nav a.router-link-exact-active')
36+
expect(files['src/App.vue']).toMatch('nav a.router-link-exact-active')
3737

3838
expect(pkg.dependencies).toHaveProperty('vue-router')
3939
})
@@ -58,7 +58,7 @@ test('use with Babel', async () => {
5858
expect(files['src/views/HomeView.vue']).toBeTruthy()
5959
expect(files['src/App.vue']).toMatch('<router-link to="/">Home</router-link>')
6060
expect(files['src/App.vue']).not.toMatch('<script>')
61-
expect(files['src/App.vue']).toMatch('#nav a.router-link-exact-active')
61+
expect(files['src/App.vue']).toMatch('nav a.router-link-exact-active')
6262

6363
expect(pkg.dependencies).toHaveProperty('vue-router')
6464
})

packages/@vue/cli-service/__tests__/serve.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ test('serve with router', async () => {
4848
() => project.run('vue-cli-service serve'),
4949
async ({ page, helpers }) => {
5050
expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`)
51-
expect(await helpers.hasElement('#nav')).toBe(true)
51+
expect(await helpers.hasElement('nav')).toBe(true)
5252
expect(await helpers.hasClass('a[href="#/"]', 'router-link-exact-active')).toBe(true)
5353
expect(await helpers.hasClass('a[href="#/about"]', 'router-link-exact-active')).toBe(false)
5454

5555
await page.click('a[href="#/about"]')
5656
await sleep(1000)
5757
expect(await helpers.getText('h1')).toMatch(`This is an about page`)
58-
expect(await helpers.hasElement('#nav')).toBe(true)
58+
expect(await helpers.hasElement('nav')).toBe(true)
5959
expect(await helpers.hasClass('a[href="#/"]', 'router-link-exact-active')).toBe(false)
6060
expect(await helpers.hasClass('a[href="#/about"]', 'router-link-exact-active')).toBe(true)
6161
}
@@ -72,14 +72,14 @@ test('serve with legacy router option', async () => {
7272
() => project.run('vue-cli-service serve'),
7373
async ({ page, helpers }) => {
7474
expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`)
75-
expect(await helpers.hasElement('#nav')).toBe(true)
75+
expect(await helpers.hasElement('nav')).toBe(true)
7676
expect(await helpers.hasClass('a[href="/"]', 'router-link-exact-active')).toBe(true)
7777
expect(await helpers.hasClass('a[href="/about"]', 'router-link-exact-active')).toBe(false)
7878

7979
await page.click('a[href="/about"]')
8080
await sleep(1000)
8181
expect(await helpers.getText('h1')).toMatch(`This is an about page`)
82-
expect(await helpers.hasElement('#nav')).toBe(true)
82+
expect(await helpers.hasElement('nav')).toBe(true)
8383
expect(await helpers.hasClass('a[href="/"]', 'router-link-exact-active')).toBe(false)
8484
expect(await helpers.hasClass('a[href="/about"]', 'router-link-exact-active')).toBe(true)
8585
}

0 commit comments

Comments
 (0)