-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1.map-filter-find.test.js
46 lines (40 loc) · 2.02 KB
/
1.map-filter-find.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
const pokemons = require('./pokeData')
const { getPokeNames, getPokemonById, getRarePokemons, getMidSizedPokemon, getAdultPokemons, getPokemonImages } = require('./1.map-filter-find');
describe('Array methods: map, filter & find: ', () => {
test('getPokeNames: Transforms an array of pokemons into an array of pokemon names', () => {
const pokemonNames = getPokeNames(pokemons)
expect(pokemonNames.length).toBe(151)
expect(pokemonNames[0]).toBe('Bulbasaur')
expect(pokemonNames[pokemonNames.length - 1]).toBe('Mew')
});
test('getPokemonById: Gets a pokemon object by their id', () => {
console.log('oh hi')
const id = 25
const pokemon = getPokemonById(pokemons, id)
expect(pokemon).toEqual(expect.objectContaining({
id: expect.any(Number),
name: expect.any(String),
height: expect.any(String),
}))
expect(pokemon.id).toBe(25)
expect(pokemon.name).toBe('Pikachu')
expect(pokemon.height).toBe('0.41 m')
})
test.skip('getRarePokemons: Transforms an array of pokemon into an array of "rare" (spawn_chance is less than 0.1) pokemon', () => {
const rarePokemon = getRarePokemons(pokemons)
expect(rarePokemon.length).toBe(81)
expect(rarePokemon.every(pokemon => pokemon.spawn_chance < 0.10)).toBe(true)
})
test.skip('getMidSizedPokemon: Gets the pokemon that weighs "38.0 kg"', () => {
const pokeMonThatWeighs35kg = getMidSizedPokemon(pokemons)
expect(pokeMonThatWeighs35kg.name).toBe("Fearow")
})
test.skip('getAdultPokemons: Transforms an array of pokemon into an array of pokemon who cannot be found in eggs', () => {
const adults = getAdultPokemons(pokemons)
expect(adults.length).toBe(78)
expect(adults.every(pokemon => pokemon.egg === "Not in Eggs")).toBe(true)
})
test.skip('getPokemonImages: Transforms an array of pokemon into an array of imageUrls', () => {
const imageUrls = getPokemonImages(pokemons)
})
})