Skip to content

Commit

Permalink
toContain -> toMatch
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 5, 2018
1 parent 267755d commit 4fb8484
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions __mocks__/inquirer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ exports.prompt = prompts => {
const message = typeof prompt.message === 'function'
? prompt.message(answers)
: prompt.message
expect(message).toContain(a.message)
expect(message).toMatch(a.message)
}

if (a.choices) {
expect(prompt.choices.length).toBe(a.choices.length)
a.choices.forEach((c, i) => {
const expected = a.choices[i]
if (expected) {
expect(prompt.choices[i].name).toContain(expected)
expect(prompt.choices[i].name).toMatch(expected)
}
})
}
Expand Down
12 changes: 6 additions & 6 deletions packages/@vue/cli-plugin-eslint/__tests__/generator.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const generateWithPlugin = require('@vue/cli-test-utils/generateWithPlugin')

it('base', async () => {
test('base', async () => {
const { pkg } = await generateWithPlugin({
id: 'eslint',
apply: require('../generator'),
Expand All @@ -14,7 +14,7 @@ it('base', async () => {
expect(pkg.devDependencies).toHaveProperty('eslint-plugin-vue')
})

it('airbnb', async () => {
test('airbnb', async () => {
const { pkg } = await generateWithPlugin({
id: 'eslint',
apply: require('../generator'),
Expand All @@ -31,7 +31,7 @@ it('airbnb', async () => {
expect(pkg.devDependencies).toHaveProperty('@vue/eslint-config-airbnb')
})

it('standard', async () => {
test('standard', async () => {
const { pkg } = await generateWithPlugin({
id: 'eslint',
apply: require('../generator'),
Expand All @@ -48,7 +48,7 @@ it('standard', async () => {
expect(pkg.devDependencies).toHaveProperty('@vue/eslint-config-standard')
})

it('lint on save', async () => {
test('lint on save', async () => {
const { pkg } = await generateWithPlugin({
id: 'eslint',
apply: require('../generator'),
Expand All @@ -62,7 +62,7 @@ it('lint on save', async () => {
})
})

it('lint on commit', async () => {
test('lint on commit', async () => {
const { pkg } = await generateWithPlugin({
id: 'eslint',
apply: require('../generator'),
Expand All @@ -78,6 +78,6 @@ it('lint on commit', async () => {
})
})

it('prettier', async () => {
test('prettier', async () => {
// TODO
})
4 changes: 2 additions & 2 deletions packages/@vue/cli-plugin-eslint/__tests__/plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ test('should work', async () => {
})
// should've applied airbnb autofix
const main = await read('src/main.js')
expect(main).toContain(';')
expect(main).toMatch(';')
// remove semicolons
await write('src/main.js', main.replace(/;/g, ''))
// lint
const child = await run('vue-cli-service lint')
expect(await read('src/main.js')).toContain(';')
expect(await read('src/main.js')).toMatch(';')

// TODO lint-on-commit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ describe('Hello.vue', () => {
const wrapper = shallow(HelloWorld, {
propsData: { msg }
})
expect(wrapper.text()).toContain(msg)
expect(wrapper.text()).toMatch(msg)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ test('base', async () => {

expect(pkg.scripts.test).toBeTruthy()
expect(pkg.devDependencies).toHaveProperty('vue-test-utils')
expect(files['test/unit/.eslintrc']).toContain('"mocha": true')
expect(files['test/unit/HelloWorld.spec.js']).toContain('// assert wrapper.text() equals msg')
expect(files['test/unit/.eslintrc']).toMatch('"mocha": true')
expect(files['test/unit/HelloWorld.spec.js']).toMatch('// assert wrapper.text() equals msg')
})

test('chai', async () => {
Expand All @@ -36,8 +36,8 @@ test('chai', async () => {
expect(pkg.devDependencies).toHaveProperty('vue-test-utils')

const spec = files['test/unit/HelloWorld.spec.js']
expect(spec).toContain(`import { expect } from 'chai'`)
expect(spec).toContain(`expect(wrapper.text()).to.include(msg)`)
expect(spec).toMatch(`import { expect } from 'chai'`)
expect(spec).toMatch(`expect(wrapper.text()).to.include(msg)`)
})

test('chai', async () => {
Expand All @@ -55,6 +55,6 @@ test('chai', async () => {
expect(pkg.devDependencies).toHaveProperty('vue-test-utils')

const spec = files['test/unit/HelloWorld.spec.js']
expect(spec).toContain(`import expect from 'expect'`)
expect(spec).toContain(`expect(wrapper.text()).toContain(msg)`)
expect(spec).toMatch(`import expect from 'expect'`)
expect(spec).toMatch(`expect(wrapper.text()).toMatch(msg)`)
})
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Hello.vue', () => {
propsData: { msg }
})
<%_ if (options.assertionLibrary === 'expect') { _%>
expect(wrapper.text()).toContain(msg)
expect(wrapper.text()).toMatch(msg)
<%_ } else if (options.assertionLibrary === 'chai') { _%>
expect(wrapper.text()).to.include(msg)
<%_ } else { _%>
Expand Down
12 changes: 6 additions & 6 deletions packages/@vue/cli/lib/__tests__/Generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ test('api: render fs directory', async () => {

await generator.generate()

expect(fs.readFileSync('/foo.js', 'utf-8')).toContain('foo(1)')
expect(fs.readFileSync('/bar/bar.js', 'utf-8')).toContain('bar(2)')
expect(fs.readFileSync('/foo.js', 'utf-8')).toMatch('foo(1)')
expect(fs.readFileSync('/bar/bar.js', 'utf-8')).toMatch('bar(2)')
})

test('api: render object', async () => {
Expand All @@ -233,8 +233,8 @@ test('api: render object', async () => {

await generator.generate()

expect(fs.readFileSync('/foo1.js', 'utf-8')).toContain('foo(2)')
expect(fs.readFileSync('/bar/bar1.js', 'utf-8')).toContain('bar(3)')
expect(fs.readFileSync('/foo1.js', 'utf-8')).toMatch('foo(2)')
expect(fs.readFileSync('/bar/bar1.js', 'utf-8')).toMatch('bar(3)')
})

test('api: render middleware', async () => {
Expand All @@ -255,8 +255,8 @@ test('api: render middleware', async () => {

await generator.generate()

expect(fs.readFileSync('/foo2.js', 'utf-8')).toContain('foo(3)')
expect(fs.readFileSync('/bar/bar2.js', 'utf-8')).toContain('bar(3)')
expect(fs.readFileSync('/foo2.js', 'utf-8')).toMatch('foo(3)')
expect(fs.readFileSync('/bar/bar2.js', 'utf-8')).toMatch('bar(3)')
})

test('api: hasPlugin', () => {
Expand Down

0 comments on commit 4fb8484

Please sign in to comment.