Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinav Kumar <[email protected]>
  • Loading branch information
abhinavkrin committed Aug 14, 2024
1 parent 982228d commit 9c8d53f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/meteor/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ export default {

testMatch: [
'<rootDir>/app/livechat/server/business-hour/**/*.spec.ts?(x)',
'<rootDir>/tests/unit/app/livechat/server/hooks/beforeNewRoom.spec.ts',
'<rootDir>/app/livechat/server/api/**/*.spec.ts',
'<rootDir>/ee/app/authorization/server/validateUserRoles.spec.ts',
'<rootDir>/app/cloud/server/functions/supportedVersionsToken/**.spec.ts',
'<rootDir>/app/utils/lib/**.spec.ts',
],

moduleNameMapper: {
'^meteor/(.*)': '<rootDir>/tests/mocks/client/meteor.ts',
},
},
],
} satisfies Config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect } from 'chai';
import proxyquire from 'proxyquire';

import { callbacks } from '../../../../../../lib/callbacks';

proxyquire.noCallThru().load('../../../../../../ee/app/livechat-enterprise/server/hooks/beforeNewRoom.ts', {
'meteor/meteor': {
Meteor: {
Error,
},
},
});

describe('livechat.beforeRoom', () => {
it('should return roomInfo with customFields when provided', async () => {
const roomInfo = { name: 'test' };
const extraData = { customFields: { test: 'test' } };
const result = await callbacks.run('livechat.beforeRoom', roomInfo, extraData);
expect(result).to.deep.equal({ ...roomInfo, customFields: extraData.customFields });
});
});

0 comments on commit 9c8d53f

Please sign in to comment.