Skip to content

Commit

Permalink
Add t.timeout to use-t-well rule
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg authored and novemberborn committed Feb 1, 2020
1 parent 1e53817 commit 3e1102a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions rules/assertion-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ const expectedNbArguments = {
truthy: {
min: 1,
max: 2
},
timeout: {
min: 1,
max: 1
}
};

Expand Down
5 changes: 5 additions & 0 deletions test/assertion-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ruleTester.run('assertion-arguments', rule, {
testCase(false, 't.truthy(\'unicorn\', \'message\');'),
testCase(false, 't.snapshot(value, \'message\');'),
testCase(false, 't.context.plan();'),
testCase(false, 't.timeout(100);'),
testCase(false, 'foo.t.plan();'),
// Shouldn't be triggered since it's not a test file
testCase(false, 't.true(true);', false, false),
Expand Down Expand Up @@ -103,6 +104,7 @@ ruleTester.run('assertion-arguments', rule, {
testCase('always', 't.skip.is(\'same\', \'same\', \'message\');'),
testCase('always', 't.is.skip(\'same\', \'same\', \'message\');'),
testCase('always', 't.snapshot(value, \'message\');'),
testCase('always', 't.timeout(100);'),

// Shouldn't be triggered since it's not a test file
testCase('always', 't.true(true);', [], false),
Expand Down Expand Up @@ -131,6 +133,7 @@ ruleTester.run('assertion-arguments', rule, {
testCase('never', 't.skip.is(\'same\', \'same\');'),
testCase('never', 't.is.skip(\'same\', \'same\');'),
testCase('never', 't.snapshot(value);'),
testCase('never', 't.timeout(100);'),
// Shouldn't be triggered since it's not a test file
testCase('never', 't.true(true, \'message\');', [], false),

Expand Down Expand Up @@ -177,6 +180,7 @@ ruleTester.run('assertion-arguments', rule, {
testCase(false, 't.skip.is(\'same\');', tooFewError(2)),
testCase(false, 't.is.skip(\'same\');', tooFewError(2)),
testCase(false, 't.snapshot();', tooFewError(1)),
testCase(false, 't.timeout();', tooFewError(1)),

// Too many arguments
testCase(false, 't.plan(1, \'extra argument\');', tooManyError(1)),
Expand All @@ -198,6 +202,7 @@ ruleTester.run('assertion-arguments', rule, {
testCase(false, 't.skip.is(\'same\', \'same\', \'message\', \'extra argument\');', tooManyError(3)),
testCase(false, 't.is.skip(\'same\', \'same\', \'message\', \'extra argument\');', tooManyError(3)),
testCase(false, 't.snapshot(value, \'message\', \'extra argument\');', tooManyError(2)),
testCase(false, 't.timeout(1, \'extra argument\');', tooManyError(1)),

testCase('always', 't.pass();', missingError),
testCase('always', 't.fail();', missingError),
Expand Down
1 change: 1 addition & 0 deletions test/use-t-well.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ ruleTester.run('use-t-well', rule, {
testCase('a.foo();'),
testCase('t.context.foo(a, a);'),
testCase('foo.t.bar(a, a);'),
testCase('t.timeout(100);'),
// Shouldn't be triggered since it's not a test file
testCase('t.foo(a, a);', false),
testCase('t.foo;', false)
Expand Down
2 changes: 1 addition & 1 deletion util.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ const assertionMethodNames = [...assertionMethodsNumArguments.keys()];

exports.assertionMethodsNumArguments = assertionMethodsNumArguments;
exports.assertionMethods = new Set(assertionMethodNames);
exports.executionMethods = new Set(assertionMethodNames.concat(['end', 'plan', 'log']));
exports.executionMethods = new Set(assertionMethodNames.concat(['end', 'plan', 'log', 'timeout']));

0 comments on commit 3e1102a

Please sign in to comment.