Skip to content

Commit

Permalink
test: improve tslint test case (test fixing vue files)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 14, 2018
1 parent 1ded378 commit 3347015
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/@vue/cli-plugin-typescript/__tests__/tsPluginLint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,22 @@ test('should work', async () => {
const { read, write, run } = project
const main = await read('src/main.ts')
expect(main).toMatch(';')
const app = await read('src/App.vue')
expect(main).toMatch(';')
// remove semicolons
const updatedMain = main.replace(/;/g, '')
await write('src/main.ts', updatedMain)
// for Vue file, only remove semis in script section
const updatedApp = app.replace(/<script(.|\n)*\/script>/, $ => {
return $.replace(/;/g, '')
})
await write('src/App.vue', updatedApp)
// lint
await run('vue-cli-service lint')
expect(await read('src/main.ts')).toMatch(';')

const lintedApp = await read('src/App.vue')
expect(lintedApp).toMatch(';')
// test if tslint is fixing vue files properly
expect(lintedApp).toBe(app)
})

0 comments on commit 3347015

Please sign in to comment.