-
Notifications
You must be signed in to change notification settings - Fork 0
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
26 changed files
with
1,854 additions
and
182 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 was deleted.
Oops, something went wrong.
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,130 @@ | ||
export default { | ||
getMovieMock: { | ||
title: 'The Empire Strikes Back', | ||
episode_id: 5, | ||
opening_crawl: | ||
'It is a dark time for the\r\nRebellion. Although the Death\r\nStar has been destroyed,\r\nImperial troops have driven the\r\nRebel forces from their hidden\r\nbase and pursued them across\r\nthe galaxy.\r\n\r\nEvading the dreaded Imperial\r\nStarfleet, a group of freedom\r\nfighters led by Luke Skywalker\r\nhas established a new secret\r\nbase on the remote ice world\r\nof Hoth.\r\n\r\nThe evil lord Darth Vader,\r\nobsessed with finding young\r\nSkywalker, has dispatched\r\nthousands of remote probes into\r\nthe far reaches of space....', | ||
director: 'Irvin Kershner', | ||
producer: 'Gary Kurtz, Rick McCallum', | ||
release_date: '1980-05-17', | ||
characters: [ | ||
'https://swapi.co/api/people/1/', | ||
'https://swapi.co/api/people/2/', | ||
'https://swapi.co/api/people/3/', | ||
'https://swapi.co/api/people/4/', | ||
'https://swapi.co/api/people/5/', | ||
'https://swapi.co/api/people/10/', | ||
'https://swapi.co/api/people/13/', | ||
'https://swapi.co/api/people/14/', | ||
'https://swapi.co/api/people/18/', | ||
'https://swapi.co/api/people/20/', | ||
'https://swapi.co/api/people/21/', | ||
'https://swapi.co/api/people/22/', | ||
'https://swapi.co/api/people/23/', | ||
'https://swapi.co/api/people/24/', | ||
'https://swapi.co/api/people/25/', | ||
'https://swapi.co/api/people/26/' | ||
], | ||
planets: [ | ||
'https://swapi.co/api/planets/4/', | ||
'https://swapi.co/api/planets/5/', | ||
'https://swapi.co/api/planets/6/', | ||
'https://swapi.co/api/planets/27/' | ||
], | ||
starships: [ | ||
'https://swapi.co/api/starships/15/', | ||
'https://swapi.co/api/starships/10/', | ||
'https://swapi.co/api/starships/11/', | ||
'https://swapi.co/api/starships/12/', | ||
'https://swapi.co/api/starships/21/', | ||
'https://swapi.co/api/starships/22/', | ||
'https://swapi.co/api/starships/23/', | ||
'https://swapi.co/api/starships/3/', | ||
'https://swapi.co/api/starships/17/' | ||
], | ||
vehicles: [ | ||
'https://swapi.co/api/vehicles/8/', | ||
'https://swapi.co/api/vehicles/14/', | ||
'https://swapi.co/api/vehicles/16/', | ||
'https://swapi.co/api/vehicles/18/', | ||
'https://swapi.co/api/vehicles/19/', | ||
'https://swapi.co/api/vehicles/20/' | ||
], | ||
species: [ | ||
'https://swapi.co/api/species/6/', | ||
'https://swapi.co/api/species/7/', | ||
'https://swapi.co/api/species/3/', | ||
'https://swapi.co/api/species/2/', | ||
'https://swapi.co/api/species/1/' | ||
], | ||
created: '2014-12-12T11:26:24.656000Z', | ||
edited: '2017-04-19T10:57:29.544256Z', | ||
url: 'https://swapi.co/api/films/2/' | ||
}, | ||
getMoviesMock: [ | ||
{ | ||
title: 'The Empire Strikes Back', | ||
episode_id: 5, | ||
opening_crawl: | ||
'It is a dark time for the\r\nRebellion. Although the Death\r\nStar has been destroyed,\r\nImperial troops have driven the\r\nRebel forces from their hidden\r\nbase and pursued them across\r\nthe galaxy.\r\n\r\nEvading the dreaded Imperial\r\nStarfleet, a group of freedom\r\nfighters led by Luke Skywalker\r\nhas established a new secret\r\nbase on the remote ice world\r\nof Hoth.\r\n\r\nThe evil lord Darth Vader,\r\nobsessed with finding young\r\nSkywalker, has dispatched\r\nthousands of remote probes into\r\nthe far reaches of space....', | ||
director: 'Irvin Kershner', | ||
producer: 'Gary Kurtz, Rick McCallum', | ||
release_date: '1980-05-17', | ||
characters: [ | ||
'https://swapi.co/api/people/1/', | ||
'https://swapi.co/api/people/2/', | ||
'https://swapi.co/api/people/3/', | ||
'https://swapi.co/api/people/4/', | ||
'https://swapi.co/api/people/5/', | ||
'https://swapi.co/api/people/10/', | ||
'https://swapi.co/api/people/13/', | ||
'https://swapi.co/api/people/14/', | ||
'https://swapi.co/api/people/18/', | ||
'https://swapi.co/api/people/20/', | ||
'https://swapi.co/api/people/21/', | ||
'https://swapi.co/api/people/22/', | ||
'https://swapi.co/api/people/23/', | ||
'https://swapi.co/api/people/24/', | ||
'https://swapi.co/api/people/25/', | ||
'https://swapi.co/api/people/26/' | ||
], | ||
planets: [ | ||
'https://swapi.co/api/planets/4/', | ||
'https://swapi.co/api/planets/5/', | ||
'https://swapi.co/api/planets/6/', | ||
'https://swapi.co/api/planets/27/' | ||
], | ||
starships: [ | ||
'https://swapi.co/api/starships/15/', | ||
'https://swapi.co/api/starships/10/', | ||
'https://swapi.co/api/starships/11/', | ||
'https://swapi.co/api/starships/12/', | ||
'https://swapi.co/api/starships/21/', | ||
'https://swapi.co/api/starships/22/', | ||
'https://swapi.co/api/starships/23/', | ||
'https://swapi.co/api/starships/3/', | ||
'https://swapi.co/api/starships/17/' | ||
], | ||
vehicles: [ | ||
'https://swapi.co/api/vehicles/8/', | ||
'https://swapi.co/api/vehicles/14/', | ||
'https://swapi.co/api/vehicles/16/', | ||
'https://swapi.co/api/vehicles/18/', | ||
'https://swapi.co/api/vehicles/19/', | ||
'https://swapi.co/api/vehicles/20/' | ||
], | ||
species: [ | ||
'https://swapi.co/api/species/6/', | ||
'https://swapi.co/api/species/7/', | ||
'https://swapi.co/api/species/3/', | ||
'https://swapi.co/api/species/2/', | ||
'https://swapi.co/api/species/1/' | ||
], | ||
created: '2014-12-12T11:26:24.656000Z', | ||
edited: '2017-04-19T10:57:29.544256Z', | ||
url: 'https://swapi.co/api/films/2/' | ||
} | ||
], | ||
getNetworkErrorMock: { message: 'Network Error' }, | ||
getCharactersMock: [{name: 'Eze', gender: 'male', height: "300"}] | ||
}; |
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,34 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Actions dispatches LOADING when getCharacter request is successful 1`] = ` | ||
Array [ | ||
Object { | ||
"type": "LOADING", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`Actions dispatches LOADING when getCharacter request is successful 2`] = ` | ||
Array [ | ||
Object { | ||
"payload": Array [], | ||
"type": "SELECT_MOVIE", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`Actions dispatches LOADING when getMovies request is successful 1`] = ` | ||
Array [ | ||
Object { | ||
"type": "LOADING", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`Actions dispatches LOADING when getmovie request is successful 1`] = ` | ||
Array [ | ||
Object { | ||
"type": "LOADING", | ||
}, | ||
] | ||
`; |
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,98 @@ | ||
import configureStore from 'redux-mock-store'; | ||
import moxios from 'moxios'; | ||
import thunk from 'redux-thunk'; | ||
|
||
import { getMovies, getMovie, getCharacter, selectMovie } from './index'; | ||
import { LOADING, SELECT_MOVIE } from './types'; | ||
import mock from '../__mocks__/mock'; | ||
|
||
describe('Actions', () => { | ||
const mockStore = configureStore([thunk]); | ||
const store = mockStore({}); | ||
|
||
beforeEach(() => { | ||
moxios.install(); | ||
store.clearActions(); | ||
}); | ||
afterEach(() => { | ||
moxios.uninstall(); | ||
}); | ||
|
||
it(`dispatches LOADING when getMovies request is successful`, done => { | ||
moxios.wait(() => { | ||
const request = moxios.requests.mostRecent(); | ||
request.respondWith({ | ||
status: 200, | ||
response: { data: mock.setCurrentUserMock } | ||
}); | ||
}); | ||
const expectedActions = [ | ||
{ | ||
type: LOADING | ||
} | ||
]; | ||
|
||
store.dispatch(getMovies()); | ||
expect(store.getActions()).toEqual(expectedActions); | ||
expect(store.getActions()).toMatchSnapshot(); | ||
done(); | ||
}); | ||
|
||
it(`dispatches LOADING when getmovie request is successful`, done => { | ||
moxios.wait(() => { | ||
const request = moxios.requests.mostRecent(); | ||
request.respondWith({ | ||
status: 200, | ||
response: { data: mock.setCurrentUserMock } | ||
}); | ||
}); | ||
const expectedActions = [ | ||
{ | ||
type: LOADING | ||
} | ||
]; | ||
store.dispatch(getMovie('google.com')); | ||
expect(store.getActions()).toEqual(expectedActions); | ||
expect(store.getActions()).toMatchSnapshot(); | ||
done(); | ||
}); | ||
|
||
it(`dispatches LOADING when getCharacter request is successful`, done => { | ||
moxios.wait(() => { | ||
const request = moxios.requests.mostRecent(); | ||
request.respondWith({ | ||
status: 200, | ||
response: { data: mock.setCurrentUserMock } | ||
}); | ||
}); | ||
const expectedActions = [ | ||
{ | ||
type: LOADING | ||
} | ||
]; | ||
store.dispatch(getCharacter([])); | ||
expect(store.getActions()).toEqual(expectedActions); | ||
expect(store.getActions()).toMatchSnapshot(); | ||
done(); | ||
}); | ||
|
||
it(`dispatches LOADING when getCharacter request is successful`, done => { | ||
moxios.wait(() => { | ||
const request = moxios.requests.mostRecent(); | ||
request.respondWith({ | ||
status: 200, | ||
response: { data: mock.setCurrentUserMock } | ||
}); | ||
}); | ||
const expectedActions = [ | ||
{ | ||
type: SELECT_MOVIE, | ||
payload: [] | ||
} | ||
]; | ||
store.dispatch(selectMovie([])); | ||
expect(store.getActions()).toEqual(expectedActions); | ||
expect(store.getActions()).toMatchSnapshot(); | ||
done(); | ||
}); | ||
}); |
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
Oops, something went wrong.