forked from wangziqi/gongxue-base
fix permissions and teacher attendance workflows
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import dayjs from 'dayjs';
|
||||
import { buildSchedulePayload, scheduleToFormValues } from './schedule-form';
|
||||
|
||||
describe('schedule edit form mapping', () => {
|
||||
it('fills an existing schedule into editable form values', () => {
|
||||
const values = scheduleToFormValues({
|
||||
id: 3,
|
||||
classId: 1,
|
||||
classroomId: 1,
|
||||
weekDay: 5,
|
||||
subject: '语文',
|
||||
teacherId: null,
|
||||
startTime: '14:00',
|
||||
endTime: '18:00',
|
||||
startDate: '2026-07-01',
|
||||
endDate: '2026-07-31',
|
||||
});
|
||||
|
||||
expect(values.classroomId).toBe(1);
|
||||
expect(values.weekDay).toBe(5);
|
||||
expect(values.timeRange.map((item) => item.format('HH:mm'))).toEqual(['14:00', '18:00']);
|
||||
expect(values.dateRange.map((item) => item.format('YYYY-MM-DD'))).toEqual([
|
||||
'2026-07-01',
|
||||
'2026-07-31',
|
||||
]);
|
||||
});
|
||||
|
||||
it('builds the update payload from edited form values', () => {
|
||||
expect(
|
||||
buildSchedulePayload({
|
||||
classId: 1,
|
||||
classroomId: 2,
|
||||
weekDay: 6,
|
||||
subject: '作文',
|
||||
teacherId: 4,
|
||||
timeRange: [dayjs('2026-01-01 13:30'), dayjs('2026-01-01 17:20')],
|
||||
dateRange: [dayjs('2026-08-01'), dayjs('2026-08-31')],
|
||||
}),
|
||||
).toEqual({
|
||||
classId: 1,
|
||||
classroomId: 2,
|
||||
weekDay: 6,
|
||||
subject: '作文',
|
||||
teacherId: 4,
|
||||
startTime: '13:30',
|
||||
endTime: '17:20',
|
||||
startDate: '2026-08-01',
|
||||
endDate: '2026-08-31',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user