-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path2.data-mining.test.js
More file actions
79 lines (70 loc) · 2.07 KB
/
2.data-mining.test.js
File metadata and controls
79 lines (70 loc) · 2.07 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
const pokemons = require("./pokeData");
const trainers = require("./trainerData");
const gyms = require("./gymData");
const {
getTrainerPokemons,
getTrainersPokemons,
getGymLeader,
getBigGyms,
} = require("./2.data-mining");
test("getGymleader: gets the gymleader belonging to a gym", () => {
const fuchsiaCity = gyms.find((gym) => gym.city === "Fuchsia City");
const gymLeader = getGymLeader(fuchsiaCity);
expect(gymLeader).toEqual(
expect.objectContaining({
id: expect.any(Number),
name: expect.any(String),
pokemonIds: expect.any(Array),
})
);
expect(gymLeader.name).toBe("Koga");
});
test("getTrainerPokemons: gets the pokemons belonging to a trainer", () => {
const ash = trainers.find((trainer) => trainer.name === "Ash");
const teamAsh = getTrainerPokemons(ash);
expect(teamAsh).toEqual(expect.any(Array));
expect(teamAsh.map((pokemon) => pokemon.name)).toEqual(
expect.arrayContaining([
"Pikachu",
"Bulbasaur",
"Squirtle",
"Charizard",
"Pidgeotto",
"Butterfree",
])
);
});
test(`getTrainersPokemons: replaces pokemonIds with
the pokemons belonging to a trainer for an array of trainers`, () => {
const trainersWithPokemons = getTrainersPokemons();
expect(trainersWithPokemons).toEqual(expect.any(Array));
trainersWithPokemons.forEach((trainer) => {
expect(trainer).toEqual(
expect.objectContaining({
id: expect.any(Number),
name: expect.any(String),
pokemons: expect.any(Array),
})
);
trainer.pokemons.forEach((pokemon) => {
expect(pokemon).toEqual(
expect.objectContaining({
id: expect.any(Number),
name: expect.any(String),
avg_spawns: expect.any(Number),
})
);
});
});
});
test("getBigGyms: gets the city names with gym leaders who have 4 pokemons or more", () => {
const bigGymCities = getBigGyms();
expect(bigGymCities).toEqual(
expect.arrayContaining([
"Saffron City",
"Fuchsia City",
"Cinnabar Island",
"Viridian City",
])
);
});