test: 为mapper补充测试
All checks were successful
deploy to server / build-and-deploy (push) Successful in 2m56s

This commit is contained in:
2025-11-06 16:46:56 +08:00
parent 083a2695f3
commit 7ba7f4a15a
10 changed files with 629 additions and 10 deletions

View File

@ -0,0 +1,31 @@
import { expect, test, describe } from 'vitest';
/**
* 单元测试: companyProfileMapper
*/
describe('companyProfileMapper', () => {
test('convert raw data to CompanyProfileView correctly', () => {
const rawData: CompanyProfile = {
id: 1,
translations: [
{ id: 10, content: 'This is raw data of company profile' },
],
};
expect(toCompanyProfileView(rawData)).toEqual({
id: 1,
content: 'This is raw data of company profile',
});
});
test('convert raw data with missing translations', () => {
const rawData: CompanyProfile = {
id: 1,
translations: [],
};
expect(toCompanyProfileView(rawData)).toEqual({
id: 1,
content: '',
});
});
});