skill-list-mock.test.ts
1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { describe, expect, it } from 'vitest';
import { getSkillDetail, getSkillList, skillListMockFixtures } from './skill-list-mock';
describe('skill list mock contract', () => {
it('provides the minimal page-facing list and detail fields', () => {
const [skill] = skillListMockFixtures.normal.items;
expect(skill).toMatchObject({
skill_code: expect.any(String),
skill_name: expect.any(String),
description: expect.any(String),
doc_markdown: expect.any(String),
});
});
it('covers the required list and detail state fixtures', () => {
expect(Object.keys(skillListMockFixtures).sort()).toEqual([
'detailError',
'detailLoading',
'empty',
'emptyMarkdown',
'error',
'loading',
'longMarkdown',
'normal',
]);
});
it('filters by keyword across list-facing fields and markdown content', () => {
expect(getSkillList({ keyword: 'markdown' }).map((item) => item.skill_code)).toContain('imagegen');
expect(getSkillList({ keyword: 'localhost' }).map((item) => item.skill_code)).toContain('browser:browser');
});
it('returns undefined for detailError and empty markdown fixtures as expected', () => {
expect(getSkillDetail('imagegen', 'detailError')).toBeUndefined();
expect(getSkillDetail('imagegen', 'emptyMarkdown')?.doc_markdown).toBe('');
});
});