33 lines
1002 B
TypeScript
33 lines
1002 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { toLearnedSignIds } from '@/business/user-progress/mappers';
|
|
import type { UserProgressDto } from '@/shared/types/userProgress';
|
|
|
|
function createProgress(overrides: Partial<UserProgressDto> = {}): UserProgressDto {
|
|
return {
|
|
id: 'progress-1',
|
|
progress_type: 'sign_learned',
|
|
item_id: 'hello',
|
|
value: null,
|
|
score: null,
|
|
metadata: null,
|
|
organizationId: 'org-1',
|
|
campusId: 'campus-1',
|
|
userId: 'user-1',
|
|
createdAt: '2026-06-08T12:00:00.000Z',
|
|
updatedAt: '2026-06-08T12:00:00.000Z',
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe('user progress mappers', () => {
|
|
it('maps learned sign progress rows to a unique id set', () => {
|
|
const learnedSignIds = toLearnedSignIds([
|
|
createProgress({ id: '1', item_id: 'hello' }),
|
|
createProgress({ id: '2', item_id: 'help' }),
|
|
createProgress({ id: '3', item_id: 'hello' }),
|
|
]);
|
|
|
|
expect([...learnedSignIds].sort()).toEqual(['hello', 'help']);
|
|
});
|
|
});
|