Skip to content

Commit

Permalink
chore: clean up code & tests more
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Apr 29, 2022
1 parent 8ff4630 commit 3e1ac37
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 308 deletions.
267 changes: 0 additions & 267 deletions src/rules/__tests__/expect-expect.test.ts
Expand Up @@ -273,270 +273,3 @@ ruleTester.run('wildcards', rule, {
},
],
});

ruleTester.run('non-jest functions (commonjs)', rule, {
valid: [
{
code: dedent`
const { test } = require('./test-fn');
describe(test, () => {
it('should do something good', () => {
expect(test({})).toBeDefined();
});
});
`,
},
{
code: dedent`
const { test: testWithJest } = require('@jest/globals');
const { test } = require('./test-fn');
describe(test, () => {
testWithJest('should do something good', () => {
expect(test({})).toBeDefined();
});
});
`,
},
],
invalid: [
{
code: dedent`
const { test: testWithJest } = require('@jest/globals');
it('should do something good', () => {
expect(testWithJest({})).toBeDefined();
});
`,
parserOptions: { sourceType: 'module' },
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.CallExpression,
},
],
},
{
code: dedent`
const { test: testWithJest } = require('@jest/globals');
describe(test, () => {
it('should do something good', () => {
expect(testWithJest({})).toBeDefined();
});
});
`,
parserOptions: { sourceType: 'module' },
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.CallExpression,
},
],
},
{
code: dedent`
const { test: testWithJest } = require('@jest/globals');
const { test } = require('./test-fn');
describe(test, () => {
testWithJest('should do something good', () => {
//
});
});
`,
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.CallExpression,
},
],
},
],
});

ruleTester.run('non-jest functions (esm)', rule, {
valid: [
{
code: dedent`
it('should do something good', () => {
const test = obj => {};
expect(test({})).toBeDefined();
});
`,
parserOptions: { sourceType: 'module' },
},
{
code: dedent`
const test = obj => {};
it('should do something good', () => {
expect(test({})).toBeDefined();
});
`,
parserOptions: { sourceType: 'module' },
},
{
code: dedent`
const test = obj => {};
describe(test, () => {
it('should do something good', () => {
expect(test({})).toBeDefined();
});
});
`,
parserOptions: { sourceType: 'module' },
},
{
code: dedent`
import { test } from './test-fn';
describe(test, () => {
it('should do something good', () => {
expect(test({})).toBeDefined();
});
});
`,
parserOptions: { sourceType: 'module' },
},
{
code: dedent`
import { test as testWithJest } from '@jest/globals';
import { test } from './test-fn';
describe(test, () => {
testWithJest('should do something good', () => {
expect(test({})).toBeDefined();
});
});
`,
parserOptions: { sourceType: 'module' },
},
],
invalid: [
{
code: dedent`
import { it } from '@jest/globals';
it('should do something good', () => {
//
});
`,
parserOptions: { sourceType: 'module' },
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.CallExpression,
},
],
},
{
code: dedent`
import { test } from '@jest/globals';
it('should do something good', () => {
expect(test({})).toBeDefined();
});
`,
parserOptions: { sourceType: 'module' },
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.CallExpression,
},
],
},
{
code: dedent`
import { test } from '@jest/globals';
describe('value', () => {
it('should do something good', () => {
expect(test({})).toBeDefined();
});
});
`,
parserOptions: { sourceType: 'module' },
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.CallExpression,
},
],
},
{
code: dedent`
import { describe, it } from '@jest/globals';
describe('my tests', () => {
it('should do something good', () => {
//
});
});
`,
parserOptions: { sourceType: 'module' },
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.CallExpression,
},
],
},
{
code: dedent`
import { test as testWithJest } from '@jest/globals';
describe(test, () => {
it('should do something good', () => {
expect(testWithJest({})).toBeDefined();
});
});
`,
parserOptions: { sourceType: 'module' },
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.CallExpression,
},
],
},
{
code: dedent`
import { test as testWithJest } from '@jest/globals';
import { test } from './test-fn';
describe(test, () => {
testWithJest('should do something good', () => {
//
});
});
`,
parserOptions: { sourceType: 'module' },
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.CallExpression,
},
],
},
{
code: dedent`
const { test: testWithJest } = import('@jest/globals');
it('should do something good', () => {
expect(testWithJest({})).toBeDefined();
});
`,
parserOptions: { sourceType: 'module' },
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.CallExpression,
},
],
},
],
});

0 comments on commit 3e1ac37

Please sign in to comment.