forked from jest-community/eslint-plugin-jest
/
no-export.test.js
43 lines (41 loc) · 1.29 KB
/
no-export.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { RuleTester } from 'eslint';
import rule from '../no-export';
const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 2015,
},
});
ruleTester.run('no-export', rule, {
valid: [
'describe("a test", () => { expect(1).toBe(1); })',
'window.location = "hello"',
'module.somethingElse = "foo";',
],
invalid: [
{
code:
'export const myThing = "hello"; describe("a test", () => { expect(1).toBe(1);});',
parserOptions: { sourceType: 'module' },
errors: [{ endColumn: 32, column: 1, messageId: 'unexpectedExport' }],
},
{
code:
'export default function() {}; describe("a test", () => { expect(1).toBe(1);});',
parserOptions: { sourceType: 'module' },
errors: [{ endColumn: 29, column: 1, messageId: 'unexpectedExport' }],
},
{
code:
'module.exports["foo"] = function() {}; describe("a test", () => { expect(1).toBe(1);});',
errors: [{ endColumn: 22, column: 1, messageId: 'unexpectedExport' }],
},
{
code: 'module.exports = function() {};',
errors: [{ endColumn: 15, column: 1, messageId: 'unexpectedExport' }],
},
{
code: 'module.export.thing = function() {};',
errors: [{ endColumn: 20, column: 1, messageId: 'unexpectedExport' }],
},
],
});