Debian Codegraph @

fast-glob/src/providers/filters/error.spec.ts

raw
1 import * as assert from 'assert';
2
3 import Settings, { Options } from '../../settings';
4 import * as tests from '../../tests';
5 import { ErrorFilterFunction } from '../../types';
6 import ErrorFilter from './error';
7
8 function getErrorFilterInstance(options?: Options): ErrorFilter {
9 const settings = new Settings(options);
10
11 return new ErrorFilter(settings);
12 }
13
14 function getFilter(options?: Options): ErrorFilterFunction {
15 return getErrorFilterInstance(options).getFilter();
16 }
17
18 describe('Providers → Filters → Error', () => {
19 describe('Constructor', () => {
20 it('should create instance of class', () => {
21 const filter = getErrorFilterInstance();
22
23 assert.ok(filter instanceof ErrorFilter);
24 });
25 });
26
27 describe('.getFilter', () => {
28 it('should return true for ENOENT error', () => {
29 const filter = getFilter();
30
31 const actual = filter(tests.errno.getEnoent());
32
33 assert.ok(actual);
34 });
35
36 it('should return true for EPERM error when the `suppressErrors` options is enabled', () => {
37 const filter = getFilter({ suppressErrors: true });
38
39 const actual = filter(tests.errno.getEperm());
40
41 assert.ok(actual);
42 });
43
44 it('should return false for EPERM error', () => {
45 const filter = getFilter();
46
47 const actual = filter(tests.errno.getEperm());
48
49 assert.ok(!actual);
50 });
51 });
52 });