-
-
Notifications
You must be signed in to change notification settings - Fork 382
Expand file tree
/
Copy pathsetupOutputFileSystem.test.js
More file actions
60 lines (47 loc) · 1.42 KB
/
setupOutputFileSystem.test.js
File metadata and controls
60 lines (47 loc) · 1.42 KB
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
56
57
58
59
60
import memfs from "memfs";
import setupOutputFileSystem from "../../src/utils/setupOutputFileSystem";
const createFsFromVolume = jest.spyOn(memfs, "createFsFromVolume");
createFsFromVolume.mockReturnValue({
testFs: true,
});
describe("setupOutputFileSystem", () => {
afterEach(() => {
createFsFromVolume.mockClear();
});
it("should create default fs if not provided", () => {
const context = {
compiler: { options: {} },
options: {},
};
setupOutputFileSystem(context);
// make sure that this is the default fs created
expect(context.compiler.outputFileSystem.testFs).toBeTruthy();
expect(context.outputFileSystem.testFs).toBeTruthy();
expect(createFsFromVolume).toHaveBeenCalledTimes(1);
});
it("should set fs for multi compiler", () => {
const context = {
compiler: {
compilers: [{ options: {} }, { options: {} }],
},
options: {},
};
setupOutputFileSystem(context);
for (const comp of context.compiler.compilers) {
expect(comp.outputFileSystem).toBeTruthy();
}
});
it("should use provided fs with correct methods", () => {
const context = {
compiler: { options: {} },
options: {
outputFileSystem: {
join: () => {},
mkdirp: () => {},
},
},
};
setupOutputFileSystem(context);
expect(context.outputFileSystem).toEqual(context.options.outputFileSystem);
});
});