Skip to content

Commit

Permalink
Add t.teardown()
Browse files Browse the repository at this point in the history
  • Loading branch information
novemberborn committed Apr 27, 2020
1 parent 67d8f75 commit a4878cf
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 @@ -60,6 +60,10 @@ const expectedNbArguments = {
min: 1,
max: 2
},
teardown: {
min: 1,
max: 1
},
throws: {
min: 1,
max: 3
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.teardown(() => {});'),
testCase(false, 't.timeout(100);'),
testCase(false, 'foo.t.plan();'),
// Shouldn't be triggered since it's not a test file
Expand Down Expand Up @@ -104,6 +105,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.teardown(() => {});'),
testCase('always', 't.timeout(100);'),
testCase('always', 't.try(tt => tt.pass());'),
testCase('always', 't.try(tt => tt.pass(), 1, 2);'),
Expand Down Expand Up @@ -136,6 +138,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.teardown(() => {});'),
testCase('never', 't.timeout(100);'),
testCase('never', 't.try(tt => tt.pass());'),
testCase('never', 't.try(tt => tt.pass(), 1, 2);'),
Expand Down Expand Up @@ -187,6 +190,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.teardown();', tooFewError(1)),
testCase(false, 't.timeout();', tooFewError(1)),
testCase(false, 't.try();', tooFewError(1)),

Expand All @@ -210,6 +214,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.teardown(() => {}, \'extra argument\');', tooManyError(1)),
testCase(false, 't.timeout(1, \'extra argument\');', tooManyError(1)),

testCase('always', 't.pass();', 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 @@ -63,6 +63,7 @@ ruleTester.run('use-t-well', rule, {
testCase('a.foo();'),
testCase('t.context.foo(a, a);'),
testCase('foo.t.bar(a, a);'),
testCase('t.teardown(() => {});'),
testCase('t.timeout(100);'),
testCase('t.try(tt => tt.pass())'),
testCase('t.try(tt => tt.pass(), 1, 2)'),
Expand Down
2 changes: 1 addition & 1 deletion util.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ const assertionMethodNames = [...assertionMethodsNumArguments.keys()];

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

0 comments on commit a4878cf

Please sign in to comment.