-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* eslint-disable no-undef */ | ||
const portMap = require('../port-map.json'); | ||
const pokeapiProxyPort = portMap['pokeapi-proxy']; | ||
const { baseUrl } = require('./jest-utils.js'); | ||
|
||
const BASE_URL = baseUrl(pokeapiProxyPort); | ||
|
||
describe('Pokémon api', () => { | ||
it('Should return at minimum the first 151 Pokemon', async function () { | ||
const response = await fetch(new URL('/api/pokemon', BASE_URL)); | ||
const pokedex = await response.json(); | ||
expect(response.status).toBe(200); | ||
expect(pokedex.results.length).toBeGreaterThanOrEqual(151); | ||
expect(pokedex.count).toBeGreaterThanOrEqual(151); | ||
}); | ||
|
||
it('Should return Pikachu by name', async function () { | ||
const response = await fetch(new URL('/api/pokemon/pikachu', BASE_URL)); | ||
const pokemon = await response.json(); | ||
expect(response.status).toBe(200); | ||
expect(pokemon.name).toBe('pikachu'); | ||
expect(pokemon.id).toBe(25); | ||
}); | ||
|
||
it('Should return Pikachu by id', async function () { | ||
const response = await fetch(new URL('/api/pokemon/25', BASE_URL)); | ||
const pokemon = await response.json(); | ||
expect(response.status).toBe(200); | ||
expect(pokemon.name).toBe('pikachu'); | ||
expect(pokemon.id).toBe(25); | ||
}); | ||
|
||
it('Should return the female Nidoran by name', async function () { | ||
const response = await fetch(new URL('/api/pokemon/nidoran-f', BASE_URL)); | ||
const pokemon = await response.json(); | ||
expect(response.status).toBe(200); | ||
expect(pokemon.name).toBe('nidoran-f'); | ||
expect(pokemon.id).toBe(29); | ||
}); | ||
|
||
it('Should return the female Nidoran by id', async function () { | ||
const response = await fetch(new URL('/api/pokemon/29', BASE_URL)); | ||
const pokemon = await response.json(); | ||
expect(response.status).toBe(200); | ||
expect(pokemon.name).toBe('nidoran-f'); | ||
expect(pokemon.id).toBe(29); | ||
}); | ||
|
||
it('Should return Mr. Mime by name', async function () { | ||
const response = await fetch(new URL('/api/pokemon/mr-mime', BASE_URL)); | ||
const pokemon = await response.json(); | ||
expect(response.status).toBe(200); | ||
expect(pokemon.name).toBe('mr-mime'); | ||
expect(pokemon.id).toBe(122); | ||
}); | ||
|
||
it('Should return Mr. Mime by id', async function () { | ||
const response = await fetch(new URL('/api/pokemon/122', BASE_URL)); | ||
const pokemon = await response.json(); | ||
expect(response.status).toBe(200); | ||
expect(pokemon.name).toBe('mr-mime'); | ||
expect(pokemon.id).toBe(122); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters