Skip to content

Commit 924ef4f

Browse files
committed
chore :fix unit test
1 parent cd0bfbe commit 924ef4f

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

packages/generator/src/generator.spec.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { mockFsWithUnionfs } from '@sap-cloud-sdk/test-util-internal/fs-mocker';
33
mockFsWithUnionfs(jest);
44
import { join, resolve } from 'path';
5-
import { readFile } from 'fs/promises';
5+
import { readFile, readdir } from 'fs/promises';
66
import { jest } from '@jest/globals';
77
import { transports } from 'winston';
88
import { vol } from 'memfs';
@@ -47,6 +47,10 @@ describe('generator', () => {
4747
},
4848
process.cwd()
4949
);
50+
vol.mkdirSync(pathTestServiceDir, { recursive: true });
51+
vol.mkdirSync(join(pathTestServiceDir, 'sdk-metadata'), {
52+
recursive: true
53+
});
5054
vol.fromNestedJSON({ '.keep': '' }, pathTestServiceDir);
5155

5256
const options = createOptions({
@@ -126,7 +130,7 @@ describe('generator', () => {
126130
});
127131

128132
it('copies the additional files matching the glob.', async () => {
129-
const sourceFiles = await promises.readdir(
133+
const sourceFiles = await readdir(
130134
join('common', 'API_TEST_SRV')
131135
);
132136

@@ -136,14 +140,14 @@ describe('generator', () => {
136140
});
137141

138142
it('generates the options per service and writes to the given folder', async () => {
139-
const clientFile = await promises.readFile(
143+
const clientFile = await readFile(
140144
'someDir/test-service-options.json'
141145
);
142146
expect(clientFile).toBeDefined();
143147
}, 10000);
144148

145149
it('generates the api hub metadata and writes to the input folder', async () => {
146-
const sourceFiles = await promises.readdir(
150+
const sourceFiles = await readdir(
147151
join(pathTestService, '../sdk-metadata')
148152
);
149153
const clientFile = sourceFiles.find(
@@ -477,10 +481,15 @@ describe('generator', () => {
477481
vol.fromNestedJSON(
478482
{
479483
common: { '.keep': '' },
484+
logger: { API_TEST_SRV: { '.keep': '' } },
480485
'/prettier/config': JSON.stringify({ printWidth: 66 })
481486
},
482487
process.cwd()
483488
);
489+
vol.mkdirSync(pathTestServiceDir, { recursive: true });
490+
vol.mkdirSync(join(pathTestServiceDir, 'sdk-metadata'), {
491+
recursive: true
492+
});
484493
vol.fromNestedJSON({ '.keep': '' }, pathTestServiceDir);
485494
});
486495

test-resources/odata-service-specs/v2/API_TEST_SRV/sdk-metadata/API_TEST_SRV_CLIENT_JS.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"apiType": "OData",
33
"language": "JavaScript",
44
"serviceStatus": "verified",
5-
"generatorVersion": "4.5.1",
5+
"generatorVersion": "4.6.0",
66
"apiSpecificUsage": "import { apiTestSrv } from './generated/API_TEST_SRV';\n\nconst { caseTestApi } = apiTestSrv();\nconst resultPromise = caseTestApi.requestBuilder().getAll().top(5).execute({ destinationName: 'myDestinationName' });\n"
77
}

0 commit comments

Comments
 (0)