Skip to content

Commit

Permalink
added custom-event-name-casing invalid test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
devTeaa committed Oct 9, 2020
1 parent b104289 commit fba56c2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"scripts": {
"start": "npm run test:base -- --watch --growl",
"test:base": "mocha \"tests/lib/**/*.js\" --reporter dot",
"test:base": "mocha \"tests/lib/rules/custom-event-name-casing.js\" --reporter dot",
"test": "nyc npm run test:base -- \"tests/integrations/*.js\" --timeout 60000",
"debug": "mocha --inspect \"tests/lib/**/*.js\" --reporter dot --timeout 60000",
"cover": "npm run cover:test && npm run cover:report",
Expand Down
62 changes: 62 additions & 0 deletions tests/lib/rules/custom-event-name-casing.js
Expand Up @@ -336,6 +336,68 @@ tester.run('custom-event-name-casing', rule, {
"Custom event name 'barBaz' must be kebab-case.",
"Custom event name 'bazQux' must be kebab-case."
]
},
{
filename: 'test.vue',
code: `
<template>
<input
@click="$emit('input/update')">
</template>
<script>
export default {
setup(props, context) {
return {
onInput(value) {
context.emit('search/update')
}
}
},
methods: {
onClick() {
this.$emit('click/row')
}
}
}
</script>
`,
options: [{ ignores: ['/^[a-z]+(?:-[a-z]+)*:[a-z]+(?:-[a-z]+)*$/u'] }],
errors: [
"Custom event name 'input/update' must be kebab-case.",
"Custom event name 'search/update' must be kebab-case.",
"Custom event name 'click/row' must be kebab-case."
]
},
{
filename: 'test.vue',
code: `
<template>
<input
@click="$emit('input/update')">
</template>
<script>
export default {
setup(props, context) {
return {
onInput(value) {
context.emit('search/update')
}
}
},
methods: {
onClick() {
this.$emit('click/row')
}
}
}
</script>
`,
options: [{ ignores: ['input:update', 'search:update', 'click:row'] }],
errors: [
"Custom event name 'input/update' must be kebab-case.",
"Custom event name 'search/update' must be kebab-case.",
"Custom event name 'click/row' must be kebab-case."
]
}
]
})

0 comments on commit fba56c2

Please sign in to comment.