forked from Tech-at-DU/map-filter-reduce-practice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
challenge2.test.js
79 lines (63 loc) · 2.1 KB
/
challenge2.test.js
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
const musicalInstruments = require("./instruments");
const {
woodWindInstruments,
firstInstrumentLessThan10,
sumOfIndexes,
addMoreInstruments,
instrumentWithHighestPlayers,
totalNumberOfPlayers,
} = require("./challenge2");
describe("Slice method Problems", () => {
test("Test Woodwind Instruments", () => {
const clarinet = {
family: "Woodwind",
name: "Clarinet",
players: 9,
};
const harmonica = {
family: "Woodwind",
name: "Harmonica",
players: 7,
};
expect(woodWindInstruments(musicalInstruments)).toContainEqual(clarinet);
expect(woodWindInstruments(musicalInstruments)).toContainEqual(harmonica);
expect(woodWindInstruments(musicalInstruments)).toHaveLength(7);
});
});
describe("Find method problems", () => {
test("Test the first instrument with less than 10 players", () => {
expect(firstInstrumentLessThan10(musicalInstruments)).toEqual({
family: "Woodwind",
name: "Clarinet",
players: 9,
});
});
});
describe('indexOf and findIndexOf problems', () => {
test('Test the sum of the indexes of piano, accordion, harp, double bass and lyre', () => {
expect(sumOfIndexes(musicalInstruments)).toEqual(52)
});
});
describe('Push and Unshift Problems', () => {
test('Test add more instruments to the array', () => {
let extendedList = addMoreInstruments(musicalInstruments)
expect(extendedList[0]).toEqual({
"family": "Brass", "name": "Vuvuzela", "players": 15
})
expect(extendedList[(extendedList.length) - 1]).toEqual({
"family": "Woodwind", "name": "Bagpipe", "players": 12
})
});
});
describe('ForEach Problems', () => {
test('Test the total number of players', () => {
expect(totalNumberOfPlayers(musicalInstruments)).toEqual(176)
});
test('Test the instrument with the highest number of players', () => {
expect(instrumentWithHighestPlayers(musicalInstruments)).toEqual({
"family": "Brass",
"name": "Tuba",
"players": 18
})
});
});