|
| 1 | +import fs from 'fs'; |
1 | 2 | import path from 'path'; |
2 | 3 | import test from 'ava'; |
| 4 | +import pify from 'pify'; |
3 | 5 | import fn from '../'; |
4 | 6 |
|
| 7 | +const readFile = pify(fs.readFile, Promise); |
| 8 | + |
5 | 9 | const hasRule = (results, ruleId) => results[0].messages.some(x => x.ruleId === ruleId); |
6 | 10 |
|
7 | 11 | test('.lintText()', t => { |
@@ -58,3 +62,18 @@ test('.lintText() - regression test for #71', t => { |
58 | 62 | }).results; |
59 | 63 | t.is(results[0].errorCount, 0, results[0]); |
60 | 64 | }); |
| 65 | + |
| 66 | +test('lintText() - overrides support', async t => { |
| 67 | + const cwd = path.join(__dirname, 'fixtures/overrides'); |
| 68 | + const bar = path.join(cwd, 'test/bar.js'); |
| 69 | + const barResults = fn.lintText(await readFile(bar, 'utf8'), {filename: bar, cwd}).results; |
| 70 | + t.is(barResults[0].errorCount, 0, barResults[0]); |
| 71 | + |
| 72 | + const foo = path.join(cwd, 'test/foo.js'); |
| 73 | + const fooResults = fn.lintText(await readFile(foo, 'utf8'), {filename: foo, cwd}).results; |
| 74 | + t.is(fooResults[0].errorCount, 0, fooResults[0]); |
| 75 | + |
| 76 | + const index = path.join(cwd, 'test/index.js'); |
| 77 | + const indexResults = fn.lintText(await readFile(bar, 'utf8'), {filename: index, cwd}).results; |
| 78 | + t.is(indexResults[0].errorCount, 0, indexResults[0]); |
| 79 | +}); |
0 commit comments