Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions exercises/concept/train-driver/train-driver.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ function list(...values) {

describe('getListOfWagons', () => {
test('returns the correct array', () => {
expect(getListOfWagons(1, 5, 2, 7, 4)).toEqual([1, 5, 2, 7, 4]);
expect(getListOfWagons(1, 5, 2, 7, 4)).toStrictEqual([1, 5, 2, 7, 4]);
});

test('works for a few arguments', () => {
expect(getListOfWagons(1, 5)).toEqual([1, 5]);
expect(getListOfWagons(1, 5)).toStrictEqual([1, 5]);
});

test('works for a one argument', () => {
expect(getListOfWagons(1)).toEqual([1]);
expect(getListOfWagons(1)).toStrictEqual([1]);
});

test('works for many arguments', () => {
expect(getListOfWagons(1, 5, 6, 3, 9, 8, 4, 14, 24, 7)).toEqual([
expect(getListOfWagons(1, 5, 6, 3, 9, 8, 4, 14, 24, 7)).toStrictEqual([
1, 5, 6, 3, 9, 8, 4, 14, 24, 7,
]);
});
Expand All @@ -75,19 +75,19 @@ describe('fixListOfWagons', () => {
const eachWagonsID = list(3, 7, 1, 14, 10, 4, 12, 6, 23, 17, 13, 20, 8, 19);
const expected = [1, 14, 10, 4, 12, 6, 23, 17, 13, 20, 8, 19, 3, 7];

expect(fixListOfWagons(eachWagonsID)).toEqual(expected);
expect(fixListOfWagons(eachWagonsID)).toStrictEqual(expected);
});

test('works when only 3 wagons given', () => {
const eachWagonsID = list(4, 2, 1);

expect(fixListOfWagons(eachWagonsID)).toEqual([1, 4, 2]);
expect(fixListOfWagons(eachWagonsID)).toStrictEqual([1, 4, 2]);
});

test('works for a few wagons', () => {
const eachWagonsID = list(3, 4, 1, 5, 7, 9, 10);

expect(fixListOfWagons(eachWagonsID)).toEqual([1, 5, 7, 9, 10, 3, 4]);
expect(fixListOfWagons(eachWagonsID)).toStrictEqual([1, 5, 7, 9, 10, 3, 4]);
});
});

Expand All @@ -99,23 +99,29 @@ describe('correctListOfWagons', () => {
1, 8, 10, 5, 9, 3, 7, 20, 6, 11, 15, 13, 14, 17, 22, 2, 16, 19, 21,
];

expect(correctListOfWagons(eachWagonsID, missingWagons)).toEqual(expected);
expect(correctListOfWagons(eachWagonsID, missingWagons)).toStrictEqual(
expected,
);
});

test('works for short arrays', () => {
const eachWagonsID = list(1, 7, 15, 24);
const missingWagons = list(8, 6, 4);
const expected = [1, 8, 6, 4, 7, 15, 24];

expect(correctListOfWagons(eachWagonsID, missingWagons)).toEqual(expected);
expect(correctListOfWagons(eachWagonsID, missingWagons)).toStrictEqual(
expected,
);
});

test('works when missingWagons is longer', () => {
const eachWagonsID = list(1, 7, 15, 24);
const missingWagons = list(8, 6, 4, 5, 9, 21, 2, 13);
const expected = [1, 8, 6, 4, 5, 9, 21, 2, 13, 7, 15, 24];

expect(correctListOfWagons(eachWagonsID, missingWagons)).toEqual(expected);
expect(correctListOfWagons(eachWagonsID, missingWagons)).toStrictEqual(
expected,
);
});
});

Expand All @@ -136,7 +142,7 @@ describe('extendRouteInformation', () => {
temperature: '5',
};

expect(extendRouteInformation(route, moreRouteInformation)).toEqual(
expect(extendRouteInformation(route, moreRouteInformation)).toStrictEqual(
expected,
);
});
Expand All @@ -152,7 +158,7 @@ describe('extendRouteInformation', () => {
temperature: '20',
};

expect(extendRouteInformation(route, moreRouteInformation)).toEqual(
expect(extendRouteInformation(route, moreRouteInformation)).toStrictEqual(
expected,
);
});
Expand All @@ -173,7 +179,7 @@ describe('extendRouteInformation', () => {
temperature: '-6',
};

expect(extendRouteInformation(route, moreRouteInformation)).toEqual(
expect(extendRouteInformation(route, moreRouteInformation)).toStrictEqual(
expected,
);
});
Expand All @@ -194,7 +200,7 @@ describe('separateTimeOfArrival', () => {
{ from: 'Berlin', to: 'Hamburg', precipitation: '10', temperature: '5' },
];

expect(separateTimeOfArrival(route)).toEqual(expected);
expect(separateTimeOfArrival(route)).toStrictEqual(expected);
});

test('separates timeOfArrival with smaller object', () => {
Expand All @@ -210,7 +216,7 @@ describe('separateTimeOfArrival', () => {
{ from: 'Paris', to: 'London', temperature: '20' },
];

expect(separateTimeOfArrival(route)).toEqual(expected);
expect(separateTimeOfArrival(route)).toStrictEqual(expected);
});

test('separates timeOfArrival from differently ordered object', () => {
Expand All @@ -232,6 +238,6 @@ describe('separateTimeOfArrival', () => {
},
];

expect(separateTimeOfArrival(route)).toEqual(expected);
expect(separateTimeOfArrival(route)).toStrictEqual(expected);
});
});