-
Notifications
You must be signed in to change notification settings - Fork 0
/
sortdata.test.ts
126 lines (123 loc) · 3.13 KB
/
sortdata.test.ts
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
119
120
121
122
123
124
125
126
import {sortData} from './src/utils/sortdata';
interface creature {
__typename: string;
id: string;
image: string;
name: string;
}
const data: Array<creature> = [
{
__typename: 'Creature',
id: '17f6a3ceea8l0i6yrr9i9li6sityc',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a3ceea8l0i6yrr9i9li6sityc.png',
name: 'Arcane Sphere Of Faces',
},
{
__typename: 'Creature',
id: '17f6a0bda2cl0i6yrtkvf0vjp9puf',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a0bda2cl0i6yrtkvf0vjp9puf.png',
name: 'A - begins with A',
},
{
__typename: 'Creature',
id: '17f6a4a6036l0i6yrvd9spb0xhw8tg',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a4a6036l0i6yrvd9spb0xhw8tg.png',
name: 'B - begins with B',
},
{
__typename: 'Creature',
id: '17f6a47bf80l0i6ys0d6zu6xbqlwu2',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a47bf80l0i6ys0d6zu6xbqlwu2.png',
name: 'C - begins with c',
},
{
__typename: 'Creature',
id: '17f6a58d8d2l0i6ys2scc9vx91u6pp',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a58d8d2l0i6ys2scc9vx91u6pp.png',
name: 'D - begins with D',
},
{
__typename: 'Creature',
id: '17f6a170239l0i6ysg3xam4t0zopmn',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a170239l0i6ysg3xam4t0zopmn.png',
name: 'E begins with E',
},
];
const result = [
{
title: 'A',
data: [
{
__typename: 'Creature',
id: '17f6a3ceea8l0i6yrr9i9li6sityc',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a3ceea8l0i6yrr9i9li6sityc.png',
name: 'Arcane Sphere Of Faces',
},
{
__typename: 'Creature',
id: '17f6a0bda2cl0i6yrtkvf0vjp9puf',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a0bda2cl0i6yrtkvf0vjp9puf.png',
name: 'A - begins with A',
},
],
},
{
title: 'B',
data: [
{
__typename: 'Creature',
id: '17f6a4a6036l0i6yrvd9spb0xhw8tg',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a4a6036l0i6yrvd9spb0xhw8tg.png',
name: 'B - begins with B',
},
],
},
{
title: 'C',
data: [
{
__typename: 'Creature',
id: '17f6a47bf80l0i6ys0d6zu6xbqlwu2',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a47bf80l0i6ys0d6zu6xbqlwu2.png',
name: 'C - begins with c',
},
],
},
{
title: 'D',
data: [
{
__typename: 'Creature',
id: '17f6a58d8d2l0i6ys2scc9vx91u6pp',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a58d8d2l0i6ys2scc9vx91u6pp.png',
name: 'D - begins with D',
},
],
},
{
title: 'E',
data: [
{
__typename: 'Creature',
id: '17f6a170239l0i6ysg3xam4t0zopmn',
image:
'https://eldenring.fanapis.com/images/creatures/17f6a170239l0i6ysg3xam4t0zopmn.png',
name: 'E begins with E',
},
],
},
];
test('data is correct', () => {
expect(sortData(data)).toEqual(result);
});