From b1494b1c71f9ab1c53659a94867e80ca0d0850a3 Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Mon, 15 Apr 2024 18:33:34 +0800 Subject: [PATCH] fix: unit test Signed-off-by: SuZhou-Joe --- .../workspace_id_consumer_wrapper.test.ts | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.test.ts b/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.test.ts index 741d7ef3662e..f9fa276e820e 100644 --- a/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.test.ts +++ b/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.test.ts @@ -88,28 +88,21 @@ describe('WorkspaceIdConsumerWrapper', () => { ); }); - it(`Should throw error when trying to create unallowed type within a workspace`, async () => { - expect(() => - wrapperClient.bulkCreate([ - getSavedObject({ - type: 'config', - id: 'foo', - }), - ]) - ).toThrow('type: config is not allowed to create within a workspace.'); + it(`Should skip the objects when trying to create unallowed type within a workspace`, async () => { + await wrapperClient.bulkCreate([ + getSavedObject({ + type: 'config', + id: 'foo', + }), + getSavedObject({ + type: DATA_SOURCE_SAVED_OBJECT_TYPE, + id: 'foo', + }), + ]); - expect(() => - wrapperClient.bulkCreate([ - getSavedObject({ - type: DATA_SOURCE_SAVED_OBJECT_TYPE, - id: 'foo', - }), - getSavedObject({ - type: UI_SETTINGS_SAVED_OBJECTS_TYPE, - id: 'bar', - }), - ]) - ).toThrow('type: data-source, type: config are not allowed to create within a workspace.'); + expect(mockedClient.bulkCreate).toBeCalledWith([], { + workspaces: ['foo'], + }); }); });