Skip to content

Commit adc49a2

Browse files
committed
Fix test template
1 parent 748ada3 commit adc49a2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

templates/javascript/api_test.mustache

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ describe('{{classname}}', () => {
3333
const response = await instance.{{operationId}}WithHttpInfo();
3434
{{/hasParams}}
3535

36-
expect(response).to.have.property('statusCode');
37-
expect(response.statusCode).to.equal({{code}})
36+
expect(response.response).to.have.property('statusCode');
37+
expect(response.response.statusCode).to.equal({{responses.0.code}})
3838
{{#responses}}
3939
{{#-first}}
4040
{{#schema}}
41-
expect(response).to.have.property('data');
41+
assertValidResponsePayload({{code}}, response.data.payload);
4242
{{/schema}}
4343
{{/-first}}
4444
{{/responses}}
@@ -61,6 +61,10 @@ describe('{{classname}}', () => {
6161
});
6262
});
6363

64+
function assertValidResponsePayload(statusCode, payload) {
65+
if (statusCode != 204) expect(payload).to.be.ok();
66+
}
67+
6468
async function instructBackendMock(basename, response, code) {
6569
const lowerCaseCompressedBasename = basename.replace(/[\W\s]/g, "").toLowerCase();
6670
const url = `${endpoint}/response/${lowerCaseCompressedBasename}-${response}/code/${code}`;

0 commit comments

Comments
 (0)