Skip to content

Commit 6286962

Browse files
committed
Fix unit test
1 parent 88601af commit 6286962

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

packages/server/api/test/unit/openops-tables/default-workspace-database.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { createDatabaseToken } from '../../../src/app/openops-tables/create-database-token';
2+
13
const openopsCommonMock = {
24
...jest.requireActual('@openops/common'),
35
makeOpenOpsTablesPost: jest.fn(),
@@ -30,6 +32,16 @@ jest.mock('../../../src/app/openops-tables/list-databases', () => {
3032
return { listDatabases: listDatabasesMock };
3133
});
3234

35+
const listDatabaseTokensMock = jest.fn();
36+
jest.mock('../../../src/app/openops-tables/list-database-tokens', () => {
37+
return { listDatabaseTokens: listDatabaseTokensMock };
38+
});
39+
40+
const createDatabaseTokenMock = jest.fn();
41+
jest.mock('../../../src/app/openops-tables/create-database-token', () => {
42+
return { createDatabaseToken: createDatabaseTokenMock };
43+
});
44+
3345
import { OPENOPS_DEFAULT_DATABASE_NAME } from '@openops/common';
3446
import { createDefaultWorkspaceAndDatabase } from '../../../src/app/openops-tables/default-workspace-database';
3547

@@ -43,9 +55,11 @@ describe('createAdminInOpenOpsTables', () => {
4355
it('should successfully create new table Opportunities', async () => {
4456
listDatabasesMock.mockResolvedValue([]);
4557
listWorkspacesMock.mockResolvedValue([]);
58+
listDatabaseTokensMock.mockResolvedValue([]);
4659
createWorkspaceMock.mockResolvedValue({ id: 1 });
4760
createDbMock.mockResolvedValue({ id: 2 });
4861
createTableMock.mockResolvedValue({ id: 3 });
62+
createDatabaseTokenMock.mockResolvedValue({ key: 'key' });
4963

5064
await createDefaultWorkspaceAndDatabase(token);
5165

0 commit comments

Comments
 (0)