-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
700cc70
commit 9b99669
Showing
20 changed files
with
621 additions
and
340 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
.App-header { | ||
background-color: #F2F3F4; | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: black; } | ||
color: white; } |
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,57 @@ | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
import axios from 'axios'; | ||
import fetchMock from 'fetch-mock'; | ||
|
||
import { FETCH_ARTICLES } from './../types'; | ||
import { getArticles } from './../getArticles'; | ||
|
||
jest.mock('axios'); | ||
|
||
describe('testing fetching all articles', () => { | ||
it('tests retrieving all articles', () => { | ||
const testStore = configureMockStore([thunk]); | ||
const store = testStore({payload: "here"}); | ||
axios.get.mockResolvedValue({response: {data: {}}}); | ||
|
||
const expectedAction = [ | ||
{ | ||
type: FETCH_ARTICLES, | ||
payload: {} | ||
}, | ||
]; | ||
|
||
return store.dispatch(getArticles({})).then(() => { | ||
expect(store.getActions()).toEqual(expectedAction); | ||
}); | ||
}); | ||
}) | ||
|
||
|
||
|
||
|
||
// const middlewares = [thunk] | ||
// const mockStore = configureMockStore(middlewares) | ||
|
||
// describe('async actions', () => { | ||
// afterEach(() => { | ||
// fetchMock.restore() | ||
// }) | ||
|
||
// it('creates FETCH_TODOS_SUCCESS when fetching todos has been done', () => { | ||
// fetchMock.getOnce('/articles', { | ||
// payload: { todos: ['do something'] }, | ||
// headers: { 'content-type': 'application/json' } | ||
// }) | ||
|
||
// const expectedActions = [ | ||
// { type: FETCH_ARTICLES } | ||
// ] | ||
// const store = mockStore({ todos: [] }) | ||
|
||
// return store.dispatch(getArticles()).then(() => { | ||
// // return of async actions | ||
// expect(store.getActions()).toEqual(expectedActions) | ||
// }) | ||
// }) | ||
// }) |
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,39 @@ | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
import axios from 'axios'; | ||
|
||
import { NEW_ARTICLE, FETCH_ARTICLE } from './../types'; | ||
import { createArticle, fetchArticle } from './../postArticles'; | ||
|
||
jest.mock('axios'); | ||
|
||
describe('testing new article', () => { | ||
it('tests posting a new article', () => { | ||
const testStore = configureMockStore([thunk]); | ||
const store = testStore({}); | ||
axios.post.mockResolvedValue({data: {} }); | ||
|
||
const expectedAction = [ | ||
{ | ||
type: NEW_ARTICLE, | ||
payload: {} | ||
}, | ||
]; | ||
|
||
return store.dispatch(createArticle({})).then(() => { | ||
expect(store.getActions()).toEqual(expectedAction); | ||
}); | ||
}); | ||
|
||
it('tests fetching a single article', () => { | ||
const testStore = configureMockStore([thunk]); | ||
const store = testStore({}); | ||
|
||
axios.get.mockResolvedValue({response: {data: {}}}); | ||
|
||
const expectedAction = [{type: FETCH_ARTICLE}]; | ||
return store.dispatch(fetchArticle({})).then(() => { | ||
expect(store.getActions()).toEqual(expectedAction); | ||
}); | ||
}); | ||
}) |
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,29 @@ | ||
import {createStore, applyMiddleware, compose } from 'redux'; | ||
import rootReducer from './../../reducers'; | ||
import thunk from 'redux-thunk'; | ||
|
||
const initialState = {}; | ||
const middleware = [thunk]; | ||
|
||
export const testStore = (initialState) => { | ||
const store = applyMiddleware(...middleware)(createStore); | ||
return store(rootReducer, initialState); | ||
}; | ||
|
||
|
||
// import {createStore, applyMiddleware, compose } from 'redux'; | ||
// import thunk from 'redux-thunk'; | ||
|
||
// import rootReducer from './../../reducers'; | ||
|
||
// const initialState = {}; | ||
// const middleware = [thunk]; | ||
|
||
// const testStore = createStore( | ||
// rootReducer, | ||
// initialState, compose( | ||
// applyMiddleware(...middleware), | ||
// window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() | ||
// )); | ||
|
||
// export default testStore; |
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.
Oops, something went wrong.