-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathanimation-slots.test.js
More file actions
84 lines (71 loc) · 2.35 KB
/
Copy pathanimation-slots.test.js
File metadata and controls
84 lines (71 loc) · 2.35 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { describe, it, expect } from 'vitest';
import { SLOTS, DEFAULT_ANIMATION_MAP, resolveSlot } from '../../src/runtime/animation-slots.js';
describe('SLOTS', () => {
it('is an array of slot names', () => {
expect(Array.isArray(SLOTS)).toBe(true);
expect(SLOTS.length).toBeGreaterThanOrEqual(10);
});
it('contains expected slot names', () => {
const expected = [
'idle',
'wave',
'nod',
'shake',
'think',
'celebrate',
'concern',
'bow',
'point',
'shrug',
'fidget',
'dance',
];
expect(SLOTS).toEqual(expected);
});
it('has no duplicate entries', () => {
expect(new Set(SLOTS).size).toBe(SLOTS.length);
});
});
describe('DEFAULT_ANIMATION_MAP', () => {
it('has an entry for every slot', () => {
for (const slot of SLOTS) {
expect(DEFAULT_ANIMATION_MAP).toHaveProperty(slot);
expect(typeof DEFAULT_ANIMATION_MAP[slot]).toBe('string');
}
});
it('maps idle to idle', () => {
expect(DEFAULT_ANIMATION_MAP.idle).toBe('idle');
});
it('maps celebrate to celebrate', () => {
expect(DEFAULT_ANIMATION_MAP.celebrate).toBe('celebrate');
});
});
describe('resolveSlot', () => {
it('returns default mapping when no override given', () => {
expect(resolveSlot('idle', null)).toBe('idle');
expect(resolveSlot('celebrate', null)).toBe('celebrate');
expect(resolveSlot('wave', null)).toBe(DEFAULT_ANIMATION_MAP.wave);
});
it('uses override map when slot is present', () => {
const overrides = { wave: 'custom_wave_clip' };
expect(resolveSlot('wave', overrides)).toBe('custom_wave_clip');
});
it('falls through to default when override does not contain slot', () => {
const overrides = { wave: 'custom_wave_clip' };
expect(resolveSlot('nod', overrides)).toBe(DEFAULT_ANIMATION_MAP.nod);
});
it('returns the slot name itself for unknown slots', () => {
expect(resolveSlot('unknown_slot', null)).toBe('unknown_slot');
});
it('returns the slot name for unknown slots even with overrides', () => {
const overrides = { wave: 'something' };
expect(resolveSlot('mystery', overrides)).toBe('mystery');
});
it('handles empty override map', () => {
expect(resolveSlot('think', {})).toBe(DEFAULT_ANIMATION_MAP.think);
});
it('override takes priority over default even if default exists', () => {
const overrides = { idle: 'breathing_idle' };
expect(resolveSlot('idle', overrides)).toBe('breathing_idle');
});
});