From d9c0935ab5ebd8b867eb041edddd2a07be063acc Mon Sep 17 00:00:00 2001 From: cartogram Date: Sun, 21 Jul 2019 08:41:37 -0400 Subject: [PATCH] refactor(no-try-expect): test parser and unnecessary braces --- src/rules/__tests__/no-try-expect.test.js | 58 +++++++++++------------ 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/src/rules/__tests__/no-try-expect.test.js b/src/rules/__tests__/no-try-expect.test.js index 671a39d2d..f8409ed23 100644 --- a/src/rules/__tests__/no-try-expect.test.js +++ b/src/rules/__tests__/no-try-expect.test.js @@ -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: [ { @@ -48,7 +36,11 @@ ruleTester.run('no-try-catch', rule, { expect(err).toMatch('Error'); } })`, - errors, + errors: [ + { + messageId: 'noTryExpect', + }, + ], }, { code: `it('foo', async () => { @@ -60,7 +52,11 @@ ruleTester.run('no-try-catch', rule, { } }) })`, - errors, + errors: [ + { + messageId: 'noTryExpect', + }, + ], }, ], });