-
Notifications
You must be signed in to change notification settings - Fork 1
/
3.data-mining.test.js
72 lines (62 loc) · 2.62 KB
/
3.data-mining.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
const pokemons = require('./pokeData')
const trainers = require('./trainerData')
const gyms = require('./gymData')
const {
getTrainerPokemons,
getTrainersPokemons,
getGymLeader,
getBigGyms,
getRarestGym
} = require('./3.data-mining');
describe('Array methods: map, filter, find & reduce: ', () => {
test.skip('getGymleader: gets the gymleader belonging to a gym', () => {
const fuchsiaCity = gyms.find(gym => gym.city === 'Fuchsia City')
const gymLeader = getGymLeader(fuchsiaCity, trainers)
expect(gymLeader).toEqual(expect.objectContaining({
id: expect.any(Number),
name: expect.any(String),
pokemonIds: expect.any(Array)
}))
expect(gymLeader.name).toBe('Koga')
})
test.skip('getTrainerPokemons: gets the pokemons belonging to a trainer', () => {
const ash = trainers.find(trainer => trainer.name === 'Ash')
const teamAsh = getTrainerPokemons(ash, pokemons)
expect(teamAsh).toEqual(expect.any(Array))
expect(teamAsh.map(pokemon => pokemon.name)).toEqual(expect.arrayContaining([
'Pikachu', "Bulbasaur", "Squirtle", "Charizard", "Pidgeotto", "Butterfree"
]))
});
test.skip(`getTrainersPokemons: replaces trainerIds with
the pokemons belonging to a trainer for an array of trainers`, () => {
const trainersWithPokemons = getTrainersPokemons(trainers, pokemons)
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.skip('getBigGyms: gets the city names with gym leaders who have 4 pokemons or more', () => {
const bigGymCities = getBigGyms(gyms, trainers)
expect(bigGymCities).toEqual(expect.arrayContaining([
'Saffron City',
'Fuchsia City',
'Cinnabar Island',
'Viridian City'
]))
})
test.skip('getRarestGym: gets the gym with the most legendary pokemon', () => {
const rarestGym = getRarestGym(gyms, trainers, pokemons)
expect(rarestGym).toEqual({ id: 1, city: 'Saffron City', trainerId: 2 })
})
})