Unit test for feedUtils (#14972)

* add unit test for feedUtils

* minor change
This commit is contained in:
Harsh Vador 2024-01-31 19:08:15 +05:30 committed by GitHub
parent 38295daa99
commit fb3e6e88da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,7 @@
*/
import {
getBackendFormat,
getEntityField,
getEntityFQN,
getEntityType,
@ -97,6 +98,7 @@ jest.mock('../rest/miscAPI', () => ({
jest.mock('./StringsUtils', () => ({
getEncodedFqn: jest.fn().mockImplementation((fqn) => fqn),
getDecodedFqn: jest.fn().mockImplementation((fqn) => fqn),
}));
jest.mock('./FeedUtils', () => ({
@ -138,4 +140,24 @@ describe('Feed Utils', () => {
},
]);
});
it('should return correct backend format for a given message', () => {
const message = `<#E::user::"admin"|[@admin](http://localhost:3000/users/admin)> test`;
const result = getBackendFormat(message);
// eslint-disable-next-line no-useless-escape
const expectedResult = `<#E::user::\"admin\"|<#E::user::admin|[@admin](http://localhost:3000/users/admin)>> test`;
expect(result).toStrictEqual(expectedResult);
});
it('should return correct backend format for a given message having . in username', () => {
const message = `<#E::user::"admin.test"|[@admin.test](http://localhost:3000/users/%22admin.test%22)> test`;
const result = getBackendFormat(message);
// eslint-disable-next-line no-useless-escape
const expectedResult = `<#E::user::\"admin.test\"|<#E::user::%22admin.test%22|[@admin.test](http://localhost:3000/users/%22admin.test%22)>> test`;
expect(result).toStrictEqual(expectedResult);
});
});