-
-
Notifications
You must be signed in to change notification settings - Fork 235
/
renderer.test.js
62 lines (54 loc) · 1.66 KB
/
renderer.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
/* eslint-disable sonarjs/no-duplicate-string */
const {
configureReact,
renderReact,
saveRenderedReactContent,
} = require('../lib/renderer/react');
jest.mock('../lib/utils');
jest.mock('@asyncapi/generator-react-sdk');
describe('React renderer', () => {
describe('saveRenderedReactContent', () => {
let util = undefined;
let AsyncReactSDK = undefined;
beforeAll(() => {
util = require('../lib/utils');
AsyncReactSDK = require('@asyncapi/generator-react-sdk');
});
it('works transpilation', async () => {
await configureReact('../file', '../dir', '../file');
expect(AsyncReactSDK.transpileFiles).toHaveBeenCalledTimes(1);
});
it('works rendering', async () => {
await renderReact({}, '../file', {}, '../file', '../dir', '../location', {}, false, '');
expect(AsyncReactSDK.renderTemplate).toHaveBeenCalledTimes(1);
});
it('works saving single rendered content', async () => {
const content = {
content: 'Content',
metadata: {
fileName: 'file.html',
}
};
await saveRenderedReactContent(content, '../some/path');
expect(util.writeFile).toHaveBeenCalledTimes(1);
});
it('works saving multiple rendered contents', async () => {
const content = [
{
content: 'Content1',
metadata: {
fileName: 'file1.html',
}
},
{
content: 'Content2',
metadata: {
fileName: 'file2.html',
}
},
];
await saveRenderedReactContent(content, '../some/path');
expect(util.writeFile).toHaveBeenCalledTimes(2);
});
});
});