Skip to content

Commit

Permalink
Tests: Add assertion messages (#287)
Browse files Browse the repository at this point in the history
Also move 'it' inside rule test so we don't run without an assertion.
  • Loading branch information
edg2s committed Jun 15, 2020
1 parent bcc85cb commit 321c83b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ configs.forEach( ( configPath ) => {
).join( '' );

Object.keys( rules ).forEach( ( rule ) => {
it( `Rule ${rule} is covered in invalid fixture`, () => {
const rDisableRule = new RegExp( `(/[/*]|<!--) eslint-disable(-next-line)? ([a-z-/]+, )*?${rule}($|[^a-z-])` );
// Disabled rules are covered below
if ( isEnabled( rule ) ) {
assert( rDisableRule.test( invalidFixtures ) );
}
} );
// Disabled rules are covered below
if ( isEnabled( rule ) ) {
it( `Rule ${rule} is covered in invalid fixture`, () => {
const rDisableRule = new RegExp( `(/[/*]|<!--) eslint-disable(-next-line)? ([a-z-/]+, )*?${rule}($|[^a-z-])` );
assert( rDisableRule.test( invalidFixtures ), 'eslint-disable comment found' );
} );
}
} );

const validFixtures = validFixturesFiles.map( ( file ) =>
Expand All @@ -84,11 +84,11 @@ configs.forEach( ( configPath ) => {
const rEnableRule = new RegExp( `Off: ${rule}($|[^a-z-])` );
if ( !isEnabled( rule ) ) {
it( `Rule ${rule} is covered as "off" in valid fixture`, () => {
assert( rEnableRule.test( validFixtures ) );
assert( rEnableRule.test( validFixtures ), '"off" comment found' );
} );
} else {
it( `Rule ${rule} is not covered as "off" in valid fixture`, () => {
assert( !rEnableRule.test( validFixtures ) );
assert( !rEnableRule.test( validFixtures ), '"off" comment not present' );
} );
}
} );
Expand Down

0 comments on commit 321c83b

Please sign in to comment.