test: update tests to search for the <nav> element

This commit is contained in:
Haoqun Jiang
2021-11-06 13:38:22 +08:00
parent 47b7dda506
commit 3f96e51738
2 changed files with 7 additions and 7 deletions
@@ -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')
})
@@ -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')
})
@@ -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')
})
@@ -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)
}
@@ -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)
}