-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
49 lines (44 loc) · 1007 Bytes
/
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
44
45
46
47
48
49
const { readdirSync } = require('fs');
const { join } = require('path');
const exec = require('async-execute');
/**
* fixtures directory
* @type {string}
*/
const fixtures = readdirSync(join(__dirname, 'fixtures'));
/**
* eslint binary
* @type {string}
*/
const eslint = join(__dirname, 'node_modules/.bin/eslint');
/**
* this test case config file
* @type {string}
*/
const config = join(__dirname, '.eslintrc');
/**
* Populate the variable 'result' with execution result
* @param {string} file to check
*/
const lint = (file) => exec(
[
eslint,
'-c',
config,
`"${join(__dirname, 'fixtures', file)}"`
].join(' ')
);
describe('linting tests', () => {
it.each(fixtures)(
'%s fail',
(fixture) => expect(
lint(`${fixture}/fail.js`)
).rejects.toThrow()
);
it.each(fixtures)(
'%s pass',
(fixture) => expect(
lint(`${fixture}/pass.js`)
).resolves.not.toThrow()
);
});