/
mfe-host.spec.ts
61 lines (52 loc) · 1.5 KB
/
mfe-host.spec.ts
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
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
import mfeHost from './mfe-host';
import applicationGenerator from '../application/application';
describe('MFE Host App Generator', () => {
it('should generate a host mfe app with no remotes', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace(2);
// ACT
await mfeHost(tree, {
name: 'test',
});
// ASSERT
expect(tree.read('apps/test/webpack.config.js', 'utf-8')).toMatchSnapshot();
});
it('should generate a host mfe app with a remote', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace(2);
await applicationGenerator(tree, {
name: 'remote',
mfe: true,
mfeType: 'remote',
routing: true,
port: 4201,
});
// ACT
await mfeHost(tree, {
name: 'test',
remotes: ['remote'],
});
// ASSERT
expect(
tree.read('apps/remote/webpack.config.js', 'utf-8')
).toMatchSnapshot();
expect(tree.read('apps/test/webpack.config.js', 'utf-8')).toMatchSnapshot();
});
it('should error when a host app is attempted to be generated with an incorrect remote', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace(2);
// ACT
try {
await mfeHost(tree, {
name: 'test',
remotes: ['remote'],
});
} catch (error) {
// ASSERT
expect(error.message).toEqual(
'Could not find specified remote application (remote)'
);
}
});
});