-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathget-direction-icon.spec.ts
More file actions
118 lines (102 loc) · 2.66 KB
/
get-direction-icon.spec.ts
File metadata and controls
118 lines (102 loc) · 2.66 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { describe, it, expect } from 'vitest';
import { getTurnIcon, type ValhallaStep } from './get-direction-icon';
import {
ArrowUp,
ArrowRight,
ArrowLeft,
ArrowUpRight,
ArrowUpLeft,
CornerDownRight,
CornerDownLeft,
RotateCcw,
GitMerge,
CircleDot,
} from 'lucide-react';
describe('getTurnIcon', () => {
const step = (data: Partial<ValhallaStep>): ValhallaStep => data;
it('returns U-turn icon', () => {
expect(getTurnIcon(step({ instruction: 'Make a u-turn' }))).toBe(RotateCcw);
});
it('returns merge icon', () => {
expect(getTurnIcon(step({ instruction: 'Merge onto highway' }))).toBe(
GitMerge
);
});
it('handles enter + exit roundabout as turn (right)', () => {
expect(
getTurnIcon(
step({
instruction: 'Enter the roundabout and take the 1st exit',
bearing_before: 0,
bearing_after: 90,
})
)
).toBe(ArrowUpRight);
});
it('handles exit roundabout using bearing (left)', () => {
expect(
getTurnIcon(
step({
instruction: 'Exit the roundabout',
type: 15,
bearing_before: 0,
bearing_after: 260,
})
)
).toBe(ArrowLeft);
});
it('returns roundabout icon on enter', () => {
expect(
getTurnIcon(
step({
instruction: 'Enter the roundabout',
type: 15,
})
)
).toBe(CircleDot);
});
it('returns sharp right icon', () => {
expect(getTurnIcon(step({ instruction: 'Make a sharp right' }))).toBe(
CornerDownRight
);
});
it('returns sharp left icon', () => {
expect(getTurnIcon(step({ instruction: 'Make a sharp left' }))).toBe(
CornerDownLeft
);
});
it('returns slight right icon (bear right)', () => {
expect(getTurnIcon(step({ instruction: 'Bear right onto road' }))).toBe(
ArrowUpRight
);
});
it('returns slight left icon (keep left)', () => {
expect(getTurnIcon(step({ instruction: 'Keep left to continue' }))).toBe(
ArrowUpLeft
);
});
it('returns right icon', () => {
expect(getTurnIcon(step({ instruction: 'Turn right onto road' }))).toBe(
ArrowRight
);
});
it('returns left icon (via bearing exit fallback)', () => {
expect(
getTurnIcon(
step({
instruction: 'Exit something',
bearing_before: 0,
bearing_after: 270,
})
)
).toBe(ArrowLeft);
});
it('returns straight icon', () => {
expect(getTurnIcon(step({ instruction: 'Continue straight' }))).toBe(
ArrowUp
);
});
it('returns default icon when no match', () => {
expect(getTurnIcon(step({}))).toBe(ArrowUp);
});
});