fix(admin): restore teacher profile form values

This commit is contained in:
2026-07-13 12:01:38 +08:00
parent 337d25e370
commit 8cadf8970e
3 changed files with 49 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
import { describe, expect, it } from 'vitest';
import { userProfileResponseToFormValues } from './user-profile-form';
describe('user profile form mapping', () => {
it('unwraps the nested profile returned by the user profile endpoint', () => {
expect(
userProfileResponseToFormValues({
id: 9,
username: 'teacher01',
name: '测试教师',
profile: {
joinedAt: '2026-07-01',
qualifications: '教师资格证',
subjects: ['语文', '历史'],
},
}),
).toEqual({
joinedAt: '2026-07-01',
qualifications: '教师资格证',
subjects: ['语文', '历史'],
});
});
it('returns empty form values when the user has no profile', () => {
expect(userProfileResponseToFormValues({ profile: null })).toEqual({});
});
});