-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a temporary login form add a temporary get all articles page add read one article page add a dropdown button add the star rating modal add the an on-success notification [Starts #166840975]
- Loading branch information
Showing
20 changed files
with
781 additions
and
32 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import DropLeft from '../src/components/SingleArticle/RatingsBtn/index'; | ||
|
||
|
||
describe('App', () => { | ||
let app; | ||
beforeEach(() => { | ||
app = shallow(<DropLeft />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
}); |
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,36 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import RatingsBtn from '../src/components/SingleArticle/RatingsBtn/index'; | ||
|
||
|
||
describe('App', () => { | ||
const props = { | ||
toggle: jest.fn(), | ||
dropdownOpen: false, | ||
prevState: { dropdown: false }, | ||
}; | ||
|
||
let app; | ||
beforeEach(() => { | ||
app = shallow(<RatingsBtn {...props} />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
|
||
it('toggles the dropdown menu when clicked', () => { | ||
const toggleButton = app.find('#toggle'); | ||
expect(toggleButton).toHaveLength(1); | ||
toggleButton.simulate('click'); | ||
|
||
expect(app).toMatchSnapshot(); | ||
}); | ||
it('toggles the dropdown menu if clicked', () => { | ||
app.instance().toggle(props.prevState); | ||
const render = jest.spyOn(app.instance(), 'toggle'); | ||
expect(render).toHaveBeenCalledTimes(0); | ||
}); | ||
}); |
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,40 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import RatingsModal from '../src/components/SingleArticle/RatingsModal/index'; | ||
|
||
|
||
describe('App', () => { | ||
let app; | ||
beforeEach(() => { | ||
app = shallow(<RatingsModal />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
|
||
it('tags have classes', () => { | ||
expect(app.find('_class').length).toBe(9); | ||
}); | ||
|
||
it('renders a span tag', () => { | ||
expect(app.find('span').length).toBe(1); | ||
}); | ||
|
||
it('renders a div', () => { | ||
expect(app.find('div').length).toBe(1); | ||
}); | ||
|
||
it('renders a h2 tag', () => { | ||
expect(app.find('h2').length).toBe(1); | ||
}); | ||
|
||
it('renders StarRatingComponent', () => { | ||
expect(app.find('StarRatingComponent').length).toBe(1); | ||
}); | ||
}); | ||
|
||
|
||
|
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,67 @@ | ||
import expect from 'expect'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
import moxios from 'moxios'; | ||
import * as types from '../src/actions/types'; | ||
import * as actions from '../src/actions/article.action'; | ||
import axios from '../src/config/axiosInstance'; | ||
|
||
const middlewares = [thunk]; | ||
const mockStore = configureMockStore(middlewares); | ||
|
||
const initialState = {}; | ||
const store = mockStore(initialState); | ||
|
||
|
||
describe('rate Article Tests', () => { | ||
afterEach(() => { | ||
moxios.install(axios); | ||
store.clearActions(); | ||
}); | ||
|
||
afterEach(() => moxios.uninstall(axios)); | ||
|
||
it('Returns success if rate article was successful', (done) => { | ||
const dataValue = { | ||
value: 3, | ||
}; | ||
jest.spyOn(axios, 'post').mockResolvedValue({ data: { message: '', data: {} } }); | ||
|
||
const expectedActions = [ | ||
{ | ||
type: types.RATE_ARTICLE_START, | ||
}, | ||
{ | ||
type: types.RATE_ARTICLE_SUCCESS, | ||
}, | ||
]; | ||
store.dispatch(actions.articleRating(dataValue)) | ||
.then(() => { | ||
expect(store.getActions()).toEqual(expectedActions); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
it('Return failure if rate article was unsuccessful', (done) => { | ||
|
||
jest.spyOn(axios, 'post').mockRejectedValue({ response: { data: { message: '' } } }); | ||
|
||
|
||
const expectedActions = [ | ||
{ | ||
type: types.RATE_ARTICLE_START, | ||
}, | ||
{ | ||
type: types.RATE_ARTICLE_FAILURE, | ||
}, | ||
]; | ||
|
||
store.dispatch(actions.articleRating(3)) | ||
.then(() => { | ||
expect(store.getActions()).toEqual(expectedActions); | ||
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
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.