Skip to content

Commit

Permalink
feat: add unit test
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Apr 10, 2024
1 parent 57ddd07 commit d5b8676
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { SavedObject } from '../../../../core/public';
import { httpServerMock, savedObjectsClientMock, coreMock } from '../../../../core/server/mocks';
import { WorkspaceIdConsumerWrapper } from './workspace_id_consumer_wrapper';
import { DATA_SOURCE_SAVED_OBJECT_TYPE } from '../../../../plugins/data_source/common';
import { UI_SETTINGS_SAVED_OBJECTS_TYPE } from '../../../../core/server';

describe('WorkspaceIdConsumerWrapper', () => {
const requestHandlerContext = coreMock.createRequestHandlerContext();
Expand Down Expand Up @@ -86,6 +87,30 @@ describe('WorkspaceIdConsumerWrapper', () => {
}
);
});

it(`Should throw error when trying to create unallowed type within a workspace`, async () => {
expect(() =>
wrapperClient.bulkCreate([
getSavedObject({
type: DATA_SOURCE_SAVED_OBJECT_TYPE,
id: 'foo',
}),
])
).toThrow('type: data-source is not allowed to create within a workspace.');

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.');
});
});

describe('checkConflict', () => {
Expand Down

0 comments on commit d5b8676

Please sign in to comment.