Skip to content

Commit

Permalink
refactor(no-try-expect): test parser and unnecessary braces
Browse files Browse the repository at this point in the history
  • Loading branch information
cartogram committed Jul 21, 2019
1 parent 32408ad commit d9c0935
Showing 1 changed file with 27 additions and 31 deletions.
58 changes: 27 additions & 31 deletions src/rules/__tests__/no-try-expect.test.js
Expand Up @@ -2,42 +2,30 @@ import { RuleTester } from 'eslint';
import rule from '../no-try-expect';

const ruleTester = new RuleTester({
parser: require.resolve('babel-eslint'),
});

const errors = [
{
messageId: 'noTryExpect',
parserOptions: {
ecmaVersion: 2019,
},
];
});

ruleTester.run('no-try-catch', rule, {
valid: [
{
code: `it('foo', () => {
`it('foo', () => {
expect('foo').toEqual('foo');
})`,
},
{
code: `
it('foo', () => {
expect('bar').toEqual('bar');
});
try {
})`,
`it('foo', () => {
expect('bar').toEqual('bar');
});
try {
} catch {
expect('foo').toEqual('foo');
}`,
},
{
code: `
it.skip('foo');
try {
} catch {
expect('foo').toEqual('foo');
}`,
`it.skip('foo');
try {
} catch {
expect('foo').toEqual('foo');
}`,
},
} catch {
expect('foo').toEqual('foo');
}`,
],
invalid: [
{
Expand All @@ -48,7 +36,11 @@ ruleTester.run('no-try-catch', rule, {
expect(err).toMatch('Error');
}
})`,
errors,
errors: [
{
messageId: 'noTryExpect',
},
],
},
{
code: `it('foo', async () => {
Expand All @@ -60,7 +52,11 @@ ruleTester.run('no-try-catch', rule, {
}
})
})`,
errors,
errors: [
{
messageId: 'noTryExpect',
},
],
},
],
});

0 comments on commit d9c0935

Please sign in to comment.