Skip to content

Commit 83077af

Browse files
committed
Fix typos and missing import
1 parent 921d8e5 commit 83077af

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed
Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, test, expect } from '@jest/globals';
2+
13
import {
24
getListOfWagons,
35
fixListOfWagons,
@@ -7,83 +9,91 @@ import {
79
} from './train-driver';
810

911
describe('getListOfWagons', () => {
10-
test('return the correct array', () => {
12+
test('returns the correct array', () => {
1113
expect(getListOfWagons(1, 5, 2, 7, 4)).toEqual([1, 5, 2, 7, 4]);
1214
});
1315

14-
test('works for a few arrgument', () => {
16+
test('works for a few arguments', () => {
1517
expect(getListOfWagons(1, 5)).toEqual([1, 5]);
1618
});
1719

18-
test('works for a one arrgument', () => {
20+
test('works for a one argument', () => {
1921
expect(getListOfWagons(1)).toEqual([1]);
2022
});
2123

22-
test('works for many argument', () => {
24+
test('works for many arguments', () => {
2325
expect(getListOfWagons(1, 5, 6, 3, 9, 8, 4, 14, 24, 7)).toEqual([
2426
1, 5, 6, 3, 9, 8, 4, 14, 24, 7,
2527
]);
2628
});
2729
});
2830

2931
describe('fixListOfWagons', () => {
30-
test('reorder the first 2 wagons to the end of the array', () => {
32+
test('reorders the first 2 wagons to the end of the array', () => {
3133
const eachWagonsID = [3, 7, 1, 14, 10, 4, 12, 6, 23, 17, 13, 20, 8, 19];
3234
const expected = [1, 14, 10, 4, 12, 6, 23, 17, 13, 20, 8, 19, 3, 7];
35+
3336
expect(fixListOfWagons(eachWagonsID)).toEqual(expected);
3437
});
3538

3639
test('works when only 3 wagons given', () => {
3740
const eachWagonsID = [4, 2, 1];
41+
3842
expect(fixListOfWagons(eachWagonsID)).toEqual([1, 4, 2]);
3943
});
4044

4145
test('works for a few wagons', () => {
4246
const eachWagonsID = [3, 4, 1, 5, 7, 9, 10];
47+
4348
expect(fixListOfWagons(eachWagonsID)).toEqual([1, 5, 7, 9, 10, 3, 4]);
4449
});
4550
});
4651

4752
describe('correctListOfWagons', () => {
48-
test('returns a wagon wieght list with the inserted array of values', () => {
53+
test('returns a wagon weight list with the inserted array of values', () => {
4954
const eachWagonsID = [1, 6, 11, 15, 13, 14, 17, 22, 2, 16, 19, 21];
5055
const missingWagons = [8, 10, 5, 9, 3, 7, 20];
5156
const expected = [
5257
1, 8, 10, 5, 9, 3, 7, 20, 6, 11, 15, 13, 14, 17, 22, 2, 16, 19, 21,
5358
];
59+
5460
expect(correctListOfWagons(eachWagonsID, missingWagons)).toEqual(expected);
5561
});
5662

5763
test('works for short arrays', () => {
5864
const eachWagonsID = [1, 7, 15, 24];
5965
const missingWagons = [8, 6, 4];
6066
const expected = [1, 8, 6, 4, 7, 15, 24];
67+
6168
expect(correctListOfWagons(eachWagonsID, missingWagons)).toEqual(expected);
6269
});
6370

6471
test('works when missingWagons is longer', () => {
6572
const eachWagonsID = [1, 7, 15, 24];
6673
const missingWagons = [8, 6, 4, 5, 9, 21, 2, 13];
6774
const expected = [1, 8, 6, 4, 5, 9, 21, 2, 13, 7, 15, 24];
75+
6876
expect(correctListOfWagons(eachWagonsID, missingWagons)).toEqual(expected);
6977
});
7078
});
7179

7280
describe('extendRouteInformation', () => {
73-
test('correctly extend route information', () => {
81+
test('correctly extends route information', () => {
7482
const route = { from: 'Berlin', to: 'Hamburg' };
7583
const moreRouteInformation = {
7684
timeOfArrival: '12:00',
7785
precipitation: '10',
7886
temperature: '5',
7987
};
88+
8089
const expected = {
8190
from: 'Berlin',
8291
to: 'Hamburg',
8392
timeOfArrival: '12:00',
8493
precipitation: '10',
8594
temperature: '5',
8695
};
96+
8797
expect(extendRouteInformation(route, moreRouteInformation)).toEqual(
8898
expected,
8999
);
@@ -92,75 +102,84 @@ describe('extendRouteInformation', () => {
92102
test('works when not adding precipitation', () => {
93103
const route = { from: 'Paris', to: 'London' };
94104
const moreRouteInformation = { timeOfArrival: '10:30', temperature: '20' };
105+
95106
const expected = {
96107
from: 'Paris',
97108
to: 'London',
98109
timeOfArrival: '10:30',
99110
temperature: '20',
100111
};
112+
101113
expect(extendRouteInformation(route, moreRouteInformation)).toEqual(
102114
expected,
103115
);
104116
});
105117

106-
test('works when written in diffrent order', () => {
118+
test('works when written in different order', () => {
107119
const route = { from: 'Gothenburg', to: 'Copenhagen' };
108120
const moreRouteInformation = {
109121
precipitation: '1',
110122
timeOfArrival: '21:20',
111123
temperature: '-6',
112124
};
125+
113126
const expected = {
114127
from: 'Gothenburg',
115128
to: 'Copenhagen',
116129
precipitation: '1',
117130
timeOfArrival: '21:20',
118131
temperature: '-6',
119132
};
133+
120134
expect(extendRouteInformation(route, moreRouteInformation)).toEqual(
121135
expected,
122136
);
123137
});
124138
});
125139

126140
describe('separateTimeOfArrival', () => {
127-
test('seperate timeOfArrival from object', () => {
141+
test('separates timeOfArrival from complete object', () => {
128142
const route = {
129143
from: 'Berlin',
130144
to: 'Hamburg',
131145
timeOfArrival: '12:00',
132146
precipitation: '10',
133147
temperature: '5',
134148
};
149+
135150
const expected = [
136151
'12:00',
137152
{ from: 'Berlin', to: 'Hamburg', precipitation: '10', temperature: '5' },
138153
];
154+
139155
expect(separateTimeOfArrival(route)).toEqual(expected);
140156
});
141157

142-
test('seperate timeOfArrival with shorter object', () => {
158+
test('separates timeOfArrival with smaller object', () => {
143159
const route = {
144160
from: 'Paris',
145161
to: 'London',
146162
timeOfArrival: '10:30',
147163
temperature: '20',
148164
};
165+
149166
const expected = [
150167
'10:30',
151168
{ from: 'Paris', to: 'London', temperature: '20' },
152169
];
170+
153171
expect(separateTimeOfArrival(route)).toEqual(expected);
154172
});
155173

156-
test('seperate timeOfArrival from object', () => {
174+
test('separates timeOfArrival from differently ordered object', () => {
157175
const route = {
158176
from: 'Gothenburg',
159177
to: 'Copenhagen',
160178
precipitation: '1',
161179
timeOfArrival: '21:20',
162180
temperature: '-6',
163181
};
182+
164183
const expected = [
165184
'21:20',
166185
{
@@ -170,6 +189,7 @@ describe('separateTimeOfArrival', () => {
170189
temperature: '-6',
171190
},
172191
];
192+
173193
expect(separateTimeOfArrival(route)).toEqual(expected);
174194
});
175195
});

0 commit comments

Comments
 (0)