-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
additional-formats.test.js
32 lines (25 loc) · 1.24 KB
/
additional-formats.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
const path = require('path');
const Generator = require('@asyncapi/generator');
const { readFile } = require('fs').promises;
const MAIN_TEST_RESULT_PATH = path.join('tests', 'temp', 'integrationTestResult');
const generateFolderName = () => {
// you always want to generate to new directory to make sure test runs in clear environment
return path.resolve(MAIN_TEST_RESULT_PATH, Date.now().toString());
};
describe('template integration tests for additional formats of data types', () => {
jest.setTimeout(30000);
it('should generate DTO file with proper type classes', async() => {
const outputDir = generateFolderName();
const params = {};
const kafkaExamplePath = './mocks/additional-type-formats.yml';
const generator = new Generator(path.normalize('./'), outputDir, { forceWrite: true, templateParams: params });
await generator.generateFromFile(path.resolve('tests', kafkaExamplePath));
const expectedFiles = [
'/src/main/java/com/asyncapi/model/SongPayload.java'
];
for (const index in expectedFiles) {
const file = await readFile(path.join(outputDir, expectedFiles[index]), 'utf8');
expect(file).toMatchSnapshot();
}
});
});