The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/apps/tests/server/accessors/PersistenceRead.test.ts

27 lines
1.2 KiB

import * as assert from 'node:assert';
import { describe, it } from 'node:test';
import type { RocketChatAssociationRecord } from '@rocket.chat/apps-engine/definition/metadata';
import { PersistenceRead } from '../../../src/server/accessors';
import type { PersistenceBridge } from '../../../src/server/bridges';
describe('PersistenceRead', () => {
it('usePersistenceRead', async () => {
const mockPersisBridge = {
doReadById(id: string, appId: string): Promise<object> {
return Promise.resolve({ id, appId });
},
doReadByAssociations(assocs: Array<RocketChatAssociationRecord>, appId: string): Promise<Array<object>> {
return Promise.resolve([{ appId }]);
},
} as PersistenceBridge;
assert.doesNotThrow(() => new PersistenceRead(mockPersisBridge, 'testing'));
const pr = new PersistenceRead(mockPersisBridge, 'testing');
assert.deepStrictEqual(await pr.read('thing'), { id: 'thing', appId: 'testing' });
assert.deepStrictEqual(await pr.readByAssociation({} as RocketChatAssociationRecord), [{ appId: 'testing' }]);
assert.deepStrictEqual(await pr.readByAssociations([{} as RocketChatAssociationRecord]), [{ appId: 'testing' }]);
});
});