Skip to content

Commit

Permalink
Adjust test for edit_config_family_all
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmundell authored and timopollmeier committed Oct 31, 2023
1 parent 1237e39 commit 5328e8c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/gmp/commands/__tests__/scanconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import {
createEntityResponse,
createHttp,
createHttpMany,
createActionResultResponse,
createResponse,
} from '../testing';
Expand Down Expand Up @@ -296,27 +297,30 @@ describe('ScanConfigCommand tests', () => {
},
],
},
all: {
get_nvts_response: {
nvt: [
{
_oid: 1,
cvss_base: 1.1,
},
{
_oid: 2,
cvss_base: 2.2,
},
{
_oid: 3,
cvss_base: 3.3,
},
],
},
},
});
const responseAll = createResponse({
get_config_family_response: {
get_nvts_response: {
nvt: [
{
_oid: 1,
cvss_base: 1.1,
},
{
_oid: 2,
cvss_base: 2.2,
},
{
_oid: 3,
cvss_base: 3.3,
},
],
},
},
});
const fakeHttp = createHttp(response);
const responses = [response, responseAll];
const fakeHttp = createHttpMany(responses);

expect.hasAssertions();

Expand Down
9 changes: 9 additions & 0 deletions src/gmp/commands/testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,13 @@ export const createHttp = response => ({
request: jest.fn().mockReturnValue(Promise.resolve(response)),
});

export const createHttpMany = responses => {
let i = 0;
return {
request: jest
.fn()
.mockImplementation(() => Promise.resolve(responses[i++])),
};
};

// vim: set ts=2 sw=2 tw=80:

0 comments on commit 5328e8c

Please sign in to comment.