This repository has been archived by the owner on Mar 17, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 254
/
publicPath.test.js
74 lines (62 loc) · 1.73 KB
/
publicPath.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
/* eslint-disable
prefer-destructuring,
*/
import webpack from '../helpers/compiler';
describe('Options', () => {
describe('publicPath', () => {
test('{String}', async () => {
const config = {
loader: {
test: /(png|jpg|svg)/,
options: {
publicPath: 'public_path/',
},
},
};
const stats = await webpack('fixture.js', config);
const { assets, source } = stats.toJson().modules[1];
expect({ assets, source }).toMatchSnapshot();
});
test('{String} - Without trailing slash', async () => {
const config = {
loader: {
test: /(png|jpg|svg)/,
options: {
publicPath: 'public_path',
},
},
};
const stats = await webpack('fixture.js', config);
const { assets, source } = stats.toJson().modules[1];
expect({ assets, source }).toMatchSnapshot();
});
test('{String} - URL', async () => {
const config = {
loader: {
test: /(png|jpg|svg)/,
options: {
publicPath: 'https://cdn.com/',
},
},
};
const stats = await webpack('fixture.js', config);
const { assets, source } = stats.toJson().modules[1];
expect({ assets, source }).toMatchSnapshot();
});
test('{Function}', async () => {
const config = {
loader: {
test: /(png|jpg|svg)/,
options: {
publicPath(url) {
return `public_path/${url}`;
},
},
},
};
const stats = await webpack('fixture.js', config);
const { assets, source } = stats.toJson().modules[1];
expect({ assets, source }).toMatchSnapshot();
});
});
});