Skip to content

Commit

Permalink
feat: update 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 Mar 8, 2024
1 parent 79b0164 commit d20c0ce
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/plugins/workspace/public/plugin.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { workspaceClientMock, WorkspaceClientMock } from './workspace_client.mock';
import { chromeServiceMock, coreMock } from '../../../core/public/mocks';
import { WorkspacePlugin } from './plugin';

describe('Workspace plugin', () => {
const getSetupMock = () => ({
...coreMock.createSetup(),
chrome: chromeServiceMock.createSetupContract(),
});
beforeEach(() => {
WorkspaceClientMock.mockClear();
Object.values(workspaceClientMock).forEach((item) => item.mockClear());
});
it('#setup', async () => {
const setupMock = getSetupMock();
const workspacePlugin = new WorkspacePlugin();
await workspacePlugin.setup(setupMock);
expect(WorkspaceClientMock).toBeCalledTimes(1);
});
});
7 changes: 5 additions & 2 deletions src/plugins/workspace/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Plugin } from '../../../core/public';
import { Plugin, CoreSetup } from '../../../core/public';
import { WorkspaceClient } from './workspace_client';

export class WorkspacePlugin implements Plugin<{}, {}, {}> {
public async setup() {
public async setup(core: CoreSetup) {
const workspaceClient = new WorkspaceClient(core.http, core.workspaces);
await workspaceClient.init();
return {};
}

Expand Down

0 comments on commit d20c0ce

Please sign in to comment.