Function
Static Public Summary | ||
public |
shallowRenderComponentWithFixtures(Component: ReactComponent, fixtures: ComponentFixtures): ComponentFixturesResults[] Shallow render a component multipile times with fixtures |
since 0.1.0 |
public |
async testActionSnapshot(action: Function): Promise Run an action (sync or async) and except the results to much snapshot |
since 0.1.0 |
public |
testActionSnapshotWithFixtures(fixtures: ActionsFixtures) Test actions with fixtures and snapshots |
since 0.1.0 |
public |
testComponentSnapshotsWithFixtures(Component: ReactComponent, fixtures: ComponentFixtures) Test a component with fixtures and snapshots |
since 0.1.0 |
public |
testReducerSnapshotWithFixtures(reducer: Function, fixtures: ReducerFixtures) Test a reducer with fixtures and snapshots |
since 0.1.0 |
public |
testSelectorsSnapshotWithFixtures(fixtures: Object) Test selectors with fixtures and snapshots |
since 0.1.0 |
Static Public
public shallowRenderComponentWithFixtures(Component: ReactComponent, fixtures: ComponentFixtures): ComponentFixturesResults[] since 0.1.0 source
import {shallowRenderComponentWithFixtures} from 'react-redux-test-utils'
Shallow render a component multipile times with fixtures
Params:
Name | Type | Attribute | Description |
Component | ReactComponent | Component to shallow-render |
|
fixtures | ComponentFixtures | Fixtures to render |
Example:
const components = shallowRenderComponentWithFixtures(Button, {
'should render a button': { href: 'https://google.com' },
'should render a button with icon': { href: 'https://github.com', icon: 'github' },
});
// results
[{
'should render a button': ShllowRendered(Button),
'should render a button': ShllowRendered(ButtonWithIcon),
}]
public async testActionSnapshot(action: Function): Promise since 0.1.0 source
import {testActionSnapshot} from 'react-redux-test-utils'
Run an action (sync or async) and except the results to much snapshot
Params:
Name | Type | Attribute | Description |
action | Function | Action to run |
Example:
test('should show modal', () => testActionSnapshot(showModal));
test('load user', () => testActionSnapshot(loadUser));
public testActionSnapshotWithFixtures(fixtures: ActionsFixtures) since 0.1.0 source
import {testActionSnapshotWithFixtures} from 'react-redux-test-utils'
Test actions with fixtures and snapshots
Params:
Name | Type | Attribute | Description |
fixtures | ActionsFixtures | Fixtures to test |
Example:
describe('PageActions', () => testActionSnapshotWithFixtures({
'should show notifications box': () = showNotificationsBox(),
});
// results
describe('PageActions', () => {
test('should show notifications box', () => {
// run showNotificationsBox() and test results against snapshot
});
});
describe('UserActions', () => testActionSnapshotWithFixtures({
'should login user': () = login({
username: 'some-username',
password: 'some-password',
}),
'should load update user email': () = updateEmail({
username: 'some-username',
oldEmail: 'some@email.com',
newEmail: 'some-other@email.com',
}),
});
// results
describe('UserActions', () => {
test('should login user', () => {
// run login() and test results against snapshot
});
test('should load update user email', () => {
// run updateEmail() and test results against snapshot
});
});
public testComponentSnapshotsWithFixtures(Component: ReactComponent, fixtures: ComponentFixtures) since 0.1.0 source
import {testComponentSnapshotsWithFixtures} from 'react-redux-test-utils'
Test a component with fixtures and snapshots
Params:
Name | Type | Attribute | Description |
Component | ReactComponent | Component to test |
|
fixtures | ComponentFixtures | Fixtures to test |
Example:
describe('Button', () => testComponentSnapshotsWithFixtures(Button, {
'should render a button': { href: 'https://google.com' },
'should render a button with icon': { href: 'https://github.com', icon: 'github' },
});
// results
describe('Button', () => {
test('should render a button', () => {
// renders button and test against snapshot
});
test('should render a button with icon', () => {
// renders button with icon and test against snapshot
});
});
public testReducerSnapshotWithFixtures(reducer: Function, fixtures: ReducerFixtures) since 0.1.0 source
import {testReducerSnapshotWithFixtures} from 'react-redux-test-utils'
Test a reducer with fixtures and snapshots
Params:
Name | Type | Attribute | Description |
reducer | Function | Reducer to test |
|
fixtures | ReducerFixtures | Reducer fixtures |
Example:
describe('LoginForm reducer', () => testReducerSnapshotWithFixtures(loginReducer, {
'it should update username': {
action: {
type: LOGIN_FORM_UPDATE_USERNAME,
payload: { username: 'some-username' }
}
},
'it should update password': {
action: {
type: LOGIN_FORM_UPDATE_PASSWORD,
payload: { password: 'some-password' }
}
},
'it should toggle remember-me': {
state: { rememberMe: false },
action: {
type: LOGIN_FORM_TOGGLE_REMEMBER_ME,
}
},
}));
public testSelectorsSnapshotWithFixtures(fixtures: Object) since 0.1.0 source
import {testSelectorsSnapshotWithFixtures} from 'react-redux-test-utils'
Test selectors with fixtures and snapshots
Params:
Name | Type | Attribute | Description |
fixtures | Object | key=fixture description value=selector runner function |
Example:
cost state = { user: { loggedIn: true, firstName: 'Eli', lastName: 'Ohana' } };
describe('UserSelectors', () => testSelectorsSnapshotWithFixtures({
'should select is-user-logged-in': selectIsUserLoggedIn(state),
'should select user-full-name': selectUserFullName(state),
}));