Skip to content

Commit

Permalink
no-identical-title: Target title, not the whole test
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmengels committed Nov 25, 2017
1 parent bf5e3a8 commit d3394a8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 10 deletions.
2 changes: 1 addition & 1 deletion rules/no-identical-title.js
Expand Up @@ -45,7 +45,7 @@ const create = context => {

if (isTitleUsed(usedTitleNodes, titleNode)) {
context.report({
node,
node: titleNode,
message: 'Test title is used multiple times in the same file.'
});
return;
Expand Down
68 changes: 59 additions & 9 deletions test/no-identical-title.js
Expand Up @@ -8,7 +8,9 @@ const ruleTester = avaRuleTester(test, {
}
});

const errors = [{ruleId: 'no-identical-title'}];
const ruleId = 'no-identical-title';
const message = 'Test title is used multiple times in the same file.';

const header = `const test = require('ava');\n`;

ruleTester.run('no-identical-title', rule, {
Expand Down Expand Up @@ -58,36 +60,84 @@ ruleTester.run('no-identical-title', rule, {
invalid: [
{
code: header + 'test("a", t => {}); test("a", t => {});',
errors
errors: [{
ruleId,
message,
type: 'Literal',
line: 2,
column: 26
}]
},
{
code: header + 'test(`a`, t => {}); test(`a`, t => {});',
errors
errors: [{
ruleId,
message,
type: 'TemplateLiteral',
line: 2,
column: 26
}]
},
{
code: header + 'test("a", t => {}); test.cb("a", t => {});',
errors
errors: [{
ruleId,
message,
type: 'Literal',
line: 2,
column: 29
}]
},
{
code: header + 'test(`a`, t => {}); test.cb(`a`, t => {});',
errors
errors: [{
ruleId,
message,
type: 'TemplateLiteral',
line: 2,
column: 29
}]
},
{
code: header + 'test("a", t => {}); test.cb.skip("a", t => {});',
errors
errors: [{
ruleId,
message,
type: 'Literal',
line: 2,
column: 34
}]
},
{
code: header + 'test("foo" + 1, t => {}); test("foo" + 1, t => {});',
errors
errors: [{
ruleId,
message,
type: 'BinaryExpression',
line: 2,
column: 32
}]
},
{
// eslint-disable-next-line no-template-curly-in-string
code: header + 'test(`${"foo" + 1}`, t => {}); test(`${"foo" + 1}`, t => {});',
errors
errors: [{
ruleId,
message,
type: 'TemplateLiteral',
line: 2,
column: 37
}]
},
{
code: header + 'test.todo("a"); test.todo("a");',
errors
errors: [{
ruleId,
message,
type: 'Literal',
line: 2,
column: 27
}]
}
]
});

0 comments on commit d3394a8

Please sign in to comment.