Skip to content

Commit

Permalink
test: update tests to search for the <nav> element
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Nov 6, 2021
1 parent 47b7dda commit 3f96e51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('base', async () => {
expect(files['src/views/HomeView.vue']).toBeTruthy()
expect(files['src/App.vue']).toMatch('<router-link to="/">Home</router-link>')
expect(files['src/App.vue']).not.toMatch('<script>')
expect(files['src/App.vue']).toMatch('#nav a.router-link-exact-active')
expect(files['src/App.vue']).toMatch('nav a.router-link-exact-active')

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

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

expect(pkg.dependencies).toHaveProperty('vue-router')
})
Expand Down
8 changes: 4 additions & 4 deletions packages/@vue/cli-service/__tests__/serve.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ test('serve with router', async () => {
() => project.run('vue-cli-service serve'),
async ({ page, helpers }) => {
expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`)
expect(await helpers.hasElement('#nav')).toBe(true)
expect(await helpers.hasElement('nav')).toBe(true)
expect(await helpers.hasClass('a[href="#/"]', 'router-link-exact-active')).toBe(true)
expect(await helpers.hasClass('a[href="#/about"]', 'router-link-exact-active')).toBe(false)

await page.click('a[href="#/about"]')
await sleep(1000)
expect(await helpers.getText('h1')).toMatch(`This is an about page`)
expect(await helpers.hasElement('#nav')).toBe(true)
expect(await helpers.hasElement('nav')).toBe(true)
expect(await helpers.hasClass('a[href="#/"]', 'router-link-exact-active')).toBe(false)
expect(await helpers.hasClass('a[href="#/about"]', 'router-link-exact-active')).toBe(true)
}
Expand All @@ -72,14 +72,14 @@ test('serve with legacy router option', async () => {
() => project.run('vue-cli-service serve'),
async ({ page, helpers }) => {
expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`)
expect(await helpers.hasElement('#nav')).toBe(true)
expect(await helpers.hasElement('nav')).toBe(true)
expect(await helpers.hasClass('a[href="/"]', 'router-link-exact-active')).toBe(true)
expect(await helpers.hasClass('a[href="/about"]', 'router-link-exact-active')).toBe(false)

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

1 comment on commit 3f96e51

@LisandroCaballero
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.