mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 12:27:33 +00:00
fix: improve code
This commit is contained in:
parent
ad39ff21ee
commit
96f20e3b2f
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
import { Plugin } from '@nocobase/server';
|
import { Plugin } from '@nocobase/server';
|
||||||
import { createMultiMockServer } from '@nocobase/test';
|
import { createMultiMockServer } from '@nocobase/test';
|
||||||
|
import { uid } from '@nocobase/utils';
|
||||||
|
|
||||||
describe('sync-message-manager', () => {
|
describe('sync-message-manager', () => {
|
||||||
test('subscribe + publish', async () => {
|
test('subscribe + publish', async () => {
|
||||||
@ -34,12 +35,18 @@ describe('sync-message-manager', () => {
|
|||||||
mockListener(message);
|
mockListener(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const [node1, node2] = await createMultiMockServer({ basename: 'base1', plugins: [MyPlugin] });
|
const [app1, app2] = await createMultiMockServer({
|
||||||
await node1.pm.get(MyPlugin).sendSyncMessage('message1');
|
basename: uid(),
|
||||||
|
number: 2, // 创建几个 app 实例
|
||||||
|
plugins: [MyPlugin],
|
||||||
|
});
|
||||||
|
await app1.pm.get(MyPlugin).sendSyncMessage('message1');
|
||||||
expect(mockListener).toBeCalledTimes(1);
|
expect(mockListener).toBeCalledTimes(1);
|
||||||
expect(mockListener).toHaveBeenCalledWith('message1');
|
expect(mockListener).toHaveBeenCalledWith('message1');
|
||||||
await node2.pm.get(MyPlugin).sendSyncMessage('message2');
|
await app2.pm.get(MyPlugin).sendSyncMessage('message2');
|
||||||
expect(mockListener).toBeCalledTimes(2);
|
expect(mockListener).toBeCalledTimes(2);
|
||||||
expect(mockListener).toHaveBeenCalledWith('message2');
|
expect(mockListener).toHaveBeenCalledWith('message2');
|
||||||
|
await app1.destroy();
|
||||||
|
await app2.destroy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user