mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 20:27:22 +00:00
chore: test
This commit is contained in:
parent
476d0b869c
commit
5d070fea64
@ -5,7 +5,7 @@
|
|||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"displayName": "Database source manager ",
|
"displayName": "Database source manager ",
|
||||||
"displayName.zh-CN": "外部数据源管理",
|
"displayName.zh-CN": "外部数据源管理",
|
||||||
"description": "Connect external data source to Nocobase",
|
"description": "Connect external data source to NocoBase",
|
||||||
"description.zh-CN": "将外部数据源接入Nocobase",
|
"description.zh-CN": "将外部数据源接入Nocobase",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@nocobase/client": "0.x",
|
"@nocobase/client": "0.x",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { createMockServer, MockServer } from '@nocobase/test';
|
import { createMockServer, MockServer } from '@nocobase/test';
|
||||||
|
import { DataSource } from '@nocobase/data-source-manager';
|
||||||
|
|
||||||
describe('data source', async () => {
|
describe('data source', async () => {
|
||||||
let app: MockServer;
|
let app: MockServer;
|
||||||
@ -13,5 +14,33 @@ describe('data source', async () => {
|
|||||||
await app.destroy();
|
await app.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create data source', async () => {});
|
it('should create data source', async () => {
|
||||||
|
const loadFn = vi.fn();
|
||||||
|
|
||||||
|
class MockDataSource extends DataSource {
|
||||||
|
async load(): Promise<void> {
|
||||||
|
loadFn();
|
||||||
|
}
|
||||||
|
|
||||||
|
createCollectionManager(options?: any): any {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app.dataSourceManager.factory.register('mock', MockDataSource);
|
||||||
|
|
||||||
|
await app.db.getRepository('dataSources').create({
|
||||||
|
values: {
|
||||||
|
key: 'mockInstance1',
|
||||||
|
type: 'mock',
|
||||||
|
displayName: 'Mock',
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(loadFn).toBeCalledTimes(1);
|
||||||
|
|
||||||
|
const mockDataSource = app.dataSourceManager.dataSources.get('mockInstance1');
|
||||||
|
expect(mockDataSource).toBeInstanceOf(MockDataSource);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user