|
| 1 | +import test from 'ava'; |
| 2 | +import {RuleTester} from 'eslint'; |
| 3 | +import rule from '../rules/no-ignored-test-files'; |
| 4 | + |
| 5 | +const ruleTester = new RuleTester({ |
| 6 | + env: { |
| 7 | + es6: true |
| 8 | + } |
| 9 | +}); |
| 10 | + |
| 11 | +const header = `const test = require('ava');\n`; |
| 12 | + |
| 13 | +test(() => { |
| 14 | + ruleTester.run('no-ignored-test-files', rule, { |
| 15 | + valid: [ |
| 16 | + { |
| 17 | + code: header + 'test(t => { t.pass(); });', |
| 18 | + filename: '/foo/bar/baz.js' |
| 19 | + }, |
| 20 | + { |
| 21 | + code: header + 'test(t => { t.pass(); });', |
| 22 | + filename: '/foo/not-fixtures/bar.js' |
| 23 | + }, |
| 24 | + { |
| 25 | + code: header + 'test(t => { t.pass(); });', |
| 26 | + filename: '/foo/not-helpers/bar.js' |
| 27 | + }, |
| 28 | + { |
| 29 | + code: header + 'foo(t => { t.pass(); });', |
| 30 | + filename: '/foo/bar/fixtures/baz.js' |
| 31 | + }, |
| 32 | + { |
| 33 | + code: header + 'foo(t => { t.pass(); });', |
| 34 | + filename: '/foo/bar/helpers/baz.js' |
| 35 | + }, |
| 36 | + { |
| 37 | + code: 'test(t => { t.pass(); });', |
| 38 | + filename: '/foo/bar/fixtures/baz.js' |
| 39 | + }, |
| 40 | + { |
| 41 | + code: 'test(t => { t.pass(); });', |
| 42 | + filename: '/foo/bar/helpers/baz.js' |
| 43 | + } |
| 44 | + ], |
| 45 | + invalid: [ |
| 46 | + { |
| 47 | + code: header + 'test(t => { t.pass(); });', |
| 48 | + filename: '/foo/bar/fixtures/baz.js', |
| 49 | + errors: [{message: 'Test file is ignored because it is inside a `fixtures` folder'}] |
| 50 | + }, |
| 51 | + { |
| 52 | + code: header + 'test(t => { t.pass(); });', |
| 53 | + filename: '/foo/bar/helpers/baz.js', |
| 54 | + errors: [{message: 'Test file is ignored because it is inside a `helpers` folder'}] |
| 55 | + } |
| 56 | + ] |
| 57 | + }); |
| 58 | +}); |
0 commit comments