test: 为mapper补充测试
All checks were successful
deploy to server / build-and-deploy (push) Successful in 2m56s
All checks were successful
deploy to server / build-and-deploy (push) Successful in 2m56s
This commit is contained in:
30
app/models/mappers/contactInfoMapper.test.ts
Normal file
30
app/models/mappers/contactInfoMapper.test.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { describe, test, expect } from 'vitest';
|
||||
|
||||
/**
|
||||
* 单元测试: contactInfoMapper
|
||||
*/
|
||||
describe('contactInfoMapper', () => {
|
||||
test('convert raw data to ContactInfoView correctly', () => {
|
||||
const rawData: ContactInfo = {
|
||||
id: 1,
|
||||
translations: [{ id: 10, content: 'This is raw data of contact info' }],
|
||||
};
|
||||
|
||||
expect(toContactInfoView(rawData)).toEqual({
|
||||
id: 1,
|
||||
content: 'This is raw data of contact info',
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with missing translations', () => {
|
||||
const rawData: ContactInfo = {
|
||||
id: 1,
|
||||
translations: [],
|
||||
};
|
||||
|
||||
expect(toContactInfoView(rawData)).toEqual({
|
||||
id: 1,
|
||||
content: '',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user