-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
49 lines (44 loc) · 1.34 KB
/
index.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
const JimpleMock = require('/tests/mocks/jimple.mock');
const pluginName = 'projext-plugin-webpack';
jest.mock('jimple', () => JimpleMock);
jest.mock('../package.json', () => ({ name: pluginName }));
jest.unmock('/src/index');
require('jasmine-expect');
const plugin = require('/src/index');
describe('plugin:projextWebpack', () => {
it('should register all the services', () => {
// Given
const app = {
register: jest.fn(),
set: jest.fn(),
};
let externalsFunction = null;
let result = null;
// When
plugin(app);
[[, externalsFunction]] = app.set.mock.calls;
result = externalsFunction();
// Then
expect(result).toEqual({
name: pluginName,
configuration: 'src/webpack.config.js',
external: [
'express',
'jimpex',
],
});
expect(app.set).toHaveBeenCalledTimes(1);
expect(app.set).toHaveBeenCalledWith('webpackPluginInfo', expect.any(Function));
expect(app.register).toHaveBeenCalledTimes([
'webpackConfiguration',
'webpackBuildEngine',
'webpackBaseConfiguration',
'webpackBrowserDevelopmentConfiguration',
'webpackBrowserProductionConfiguration',
'webpackLoadersConfiguration',
'webpackNodeDevelopmentConfiguration',
'webpackNodeProductionConfiguration',
'webpackMiddlewares',
].length);
});
});