From 5328e8cf09fffb4ad673dae30be0ef364a1311a5 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 30 Oct 2023 13:36:30 +0200 Subject: [PATCH] Adjust test for edit_config_family_all --- src/gmp/commands/__tests__/scanconfig.js | 40 +++++++++++++----------- src/gmp/commands/testing.js | 9 ++++++ 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/gmp/commands/__tests__/scanconfig.js b/src/gmp/commands/__tests__/scanconfig.js index e93c6569a9..a15f59db9b 100644 --- a/src/gmp/commands/__tests__/scanconfig.js +++ b/src/gmp/commands/__tests__/scanconfig.js @@ -18,6 +18,7 @@ import { createEntityResponse, createHttp, + createHttpMany, createActionResultResponse, createResponse, } from '../testing'; @@ -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(); diff --git a/src/gmp/commands/testing.js b/src/gmp/commands/testing.js index 5dda055abb..9b978655e6 100644 --- a/src/gmp/commands/testing.js +++ b/src/gmp/commands/testing.js @@ -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: