forked from webpack/webpack-cli
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache-flags.test.js
82 lines (59 loc) · 3.03 KB
/
cache-flags.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
const { run } = require('../utils/test-utils');
describe('cache related flags from core', () => {
it('should be successful with --cache ', () => {
const { stderr, stdout } = run(__dirname, ['--cache']);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`type: 'memory'`);
});
it('should be successful with --no-cache ', () => {
const { stderr, stdout } = run(__dirname, ['--no-cache']);
expect(stderr).toBeFalsy();
expect(stdout).toContain('cache: false');
});
it('should set cache.type', () => {
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem']);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`type: 'filesystem'`);
});
it('should set cache.cacheDirectory with --cache-cache-directory', () => {
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-directory', '/test-cache-path']);
expect(stderr).toBeFalsy();
expect(stdout).toContain('test-cache-path');
});
it('should set cache.cacheLocation with --cache-cache-locations', () => {
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-location', '/test-locate-cache']);
expect(stderr).toBeFalsy();
expect(stdout).toContain('test-locate-cache');
});
it('should set cache.hashAlgorithm with --cache-hash-algorithm', () => {
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-hash-algorithm', 'sha256']);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`hashAlgorithm: 'sha256'`);
});
it('should set cache.managedPaths with --cache-managed-paths', () => {
const { stderr, stdout } = run(__dirname, ['--cache-type', 'memory', '--cache-managed-paths', '/test-manage-path']);
expect(stderr).toBeFalsy();
expect(stdout).toContain('test-manage-path');
});
it('should reset cache.managedPaths with --cache-managed-paths-reset', () => {
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-managed-paths-reset']);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`managedPaths: []`);
});
it('should set cache.name with --cache-name', () => {
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-name', 'cli-test']);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`name: 'cli-test'`);
});
it('should set cache.store with --cache-store', () => {
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-store', 'pack']);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`store: 'pack'`);
});
it('should set cache.version with --cache-version', () => {
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-version', '1.1.3']);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`version: '1.1.3'`);
});
});