Skip to content

Commit d885065

Browse files
eemednovemberborn
authored andcommitted
Reflect t.assert() and changes in power-assert
1 parent cecf7a2 commit d885065

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

docs/rules/prefer-power-assert.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Translations: [Français](https://github.com/avajs/ava-docs/blob/master/fr_FR/related/eslint-plugin-ava/docs/rules/prefer-power-assert.md)
44

5-
- [`t.true()`](https://github.com/avajs/ava#truevalue-message)
5+
- [`t.assert()`](https://github.com/avajs/ava#assertvalue-message)
66
- [`t.deepEqual()`](https://github.com/avajs/ava#deepequalvalue-expected-message)
77
- [`t.notDeepEqual()`](https://github.com/avajs/ava#notdeepequalvalue-expected-message)
88
- [`t.throws()`](https://github.com/avajs/ava#throwsfunctionpromise-error-message)
@@ -21,6 +21,7 @@ import test from 'ava';
2121
test(t => {
2222
t.truthy(foo);
2323
t.falsy(foo);
24+
t.true(foo === bar);
2425
t.false(foo === bar);
2526
t.is(foo, bar);
2627
t.not(foo, bar);
@@ -36,7 +37,7 @@ test(t => {
3637
import test from 'ava';
3738

3839
test(t => {
39-
t.true(foo === bar);
40+
t.assert(foo === bar);
4041
t.deepEqual(foo, bar);
4142
t.notDeepEqual(foo, bar);
4243
t.throws(foo);

rules/prefer-power-assert.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const util = require('../util');
77

88
const notAllowed = [
99
'truthy',
10+
'true',
1011
'falsy',
1112
'false',
1213
'is',

test/prefer-power-assert.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function testNotAllowedMethod(methodName) {
3434
const notAllowedMethods = [
3535
'truthy(foo)',
3636
'falsy(foo)',
37+
'true(foo)',
3738
'false(foo)',
3839
'is(foo, bar)',
3940
'not(foo, bar)',
@@ -61,7 +62,7 @@ function testAllowedMethod(methodName) {
6162
}
6263

6364
const allowedMethods = [
64-
'true(foo)',
65+
'assert(foo)',
6566
'deepEqual(foo, bar)',
6667
'notDeepEqual(foo, bar)',
6768
'throws(block)',
@@ -78,7 +79,7 @@ function testWithModifier(modifier) {
7879
ruleTester.run('prefer-power-assert', rule, {
7980
valid: [
8081
{
81-
code: `import test from 'ava';\n test.${modifier}(t => { t.true(foo); });`
82+
code: `import test from 'ava';\n test.${modifier}(t => { t.assert(foo); });`
8283
}
8384
],
8485
invalid: [
@@ -98,7 +99,7 @@ function testDeclaration(declaration) {
9899
ruleTester.run('prefer-power-assert', rule, {
99100
valid: [
100101
{
101-
code: `${declaration}\n test(t => { t.true(foo); });`
102+
code: `${declaration}\n test(t => { t.assert(foo); });`
102103
}
103104
],
104105
invalid: [
@@ -133,7 +134,7 @@ test(t => {
133134
ruleTester.run('prefer-power-assert', rule, {
134135
valid: [
135136
{
136-
code: 'import test from \'ava\';\n test.cb(function (t) { t.true(foo); t.end(); });'
137+
code: 'import test from \'ava\';\n test.cb(function (t) { t.assert(foo); t.end(); });'
137138
},
138139
// Shouldn't be triggered since it's not a test file
139140
{

test/use-t-well.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ruleTester.run('use-t-well', rule, {
3232
testCase('t.end();'),
3333
testCase('t.pass();'),
3434
testCase('t.fail();'),
35+
testCase('t.assert(v);'),
3536
testCase('t.truthy(v);'),
3637
testCase('t.falsy(v);'),
3738
testCase('t.true(v);'),

util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ const getDocsUrl = (filename, commitHash) => {
160160
exports.getDocsUrl = getDocsUrl;
161161

162162
const assertionMethodsNumArguments = new Map([
163+
['assert', 1],
163164
['deepEqual', 2],
164165
['fail', 0],
165166
['false', 1],

0 commit comments

Comments
 (0)