-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
eslint-file.spec.ts
55 lines (43 loc) · 1.85 KB
/
eslint-file.spec.ts
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
50
51
52
53
54
55
import { containsEslint, findEslintFile } from './eslint-file';
import { Tree } from '@nrwl/devkit';
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
describe('@nrwl/linter:eslint-file', () => {
let tree: Tree;
beforeEach(() => {
tree = createTreeWithEmptyWorkspace();
});
describe('containsEslint', () => {
it('should return false when calling containsEslint without a eslint config', () => {
expect(containsEslint(tree)).toBe(false);
});
it('should return true when calling containsEslint with a .eslintrc.json config', () => {
tree.write('.eslintrc.json', '{}');
expect(containsEslint(tree)).toBe(true);
});
it('should return true when calling containsEslint with a .eslintrc.js config', () => {
tree.write('.eslintrc.js', '{}');
expect(containsEslint(tree)).toBe(true);
});
it('should return false when calling containsEslint witn an incorrect eslint file name', () => {
tree.write('.eslintrc.yaml', '{}');
expect(containsEslint(tree)).toBe(false);
});
});
describe('findEslintFile', () => {
it('should return default name when calling findEslintFile when no eslint is found', () => {
expect(findEslintFile(tree)).toBe('eslintrc.json');
});
it('should return the name of the eslint config when calling findEslintFile', () => {
tree.write('.eslintrc.json', '{}');
expect(findEslintFile(tree)).toBe('.eslintrc.json');
});
it('should return the name of the eslint config when calling findEslintFile', () => {
tree.write('.eslintrc.js', '{}');
expect(findEslintFile(tree)).toBe('.eslintrc.js');
});
it('should return default name when calling findEslintFile when no eslint is found', () => {
tree.write('.eslintrc.yaml', '{}');
expect(findEslintFile(tree)).toBe('eslintrc.json');
});
});
});