Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State: Global test runner cleanup #3789

Merged
merged 3 commits into from
Mar 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions client/state/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import nock from 'nock';
/**
* Internal dependencies
*/
import domEnvSetup from 'lib/react-test-env-setup';
import { createReduxStore } from '../';

describe( 'state', () => {
before( () => {
Expand All @@ -24,23 +24,13 @@ describe( 'state', () => {
} );

describe( 'createReduxStore', () => {
let createReduxStore;

before( () => {
domEnvSetup();
createReduxStore = require( '../' ).createReduxStore;
} );

after( () => {
domEnvSetup.cleanup();
} );

it( 'can be called without specifying initialState', () => {
const reduxStoreNoArgs = createReduxStore().getState();
const reduxStoreWithEmptyState = createReduxStore( {} ).getState();
expect( reduxStoreNoArgs ).to.be.an( 'object' );
expect( reduxStoreWithEmptyState ).to.eql( reduxStoreNoArgs );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice that this turned into a simple import, I had trouble with some of the redux middleware previously

} );

it( 'is instantiated with initialState', () => {
const user = { ID: 1234, display_name: 'test user', username: 'testuser' };
const initialState = {
Expand All @@ -52,20 +42,22 @@ describe( 'state', () => {
expect( Object.keys( reduxStoreWithCurrentUser.users.items ).length ).to.eql( 1 );
expect( reduxStoreWithCurrentUser.users.items[ 1234 ] ).to.eql( user );
} );

describe( 'invalid data', () => {
var consoleStub;
before( () => {
consoleStub = sinon.stub( console, 'error' );
sinon.stub( console, 'error' );
} );

after( () => {
consoleStub.restore();
console.error.restore();
} );

it( 'ignores non-existent keys', () => {
expect( consoleStub.calledOnce ).to.eql( false );
expect( console.error.calledOnce ).to.eql( false );
const reduxStoreNoArgs = createReduxStore().getState();
const reduxStoreBadData = createReduxStore( { some: { bad: { stuff: true } } } ).getState();
expect( reduxStoreBadData ).to.eql( reduxStoreNoArgs );
expect( consoleStub.calledOnce ).to.eql( true );
expect( console.error.calledOnce ).to.eql( true );
} );
} );
} );
Expand Down Expand Up @@ -174,9 +166,9 @@ describe( 'state', () => {
} );

describe( 'ui', () => {
require( '../users/test/actions' );
require( '../users/test/reducer' );
require( '../users/test/selectors' );
require( '../ui/test/actions' );
require( '../ui/test/reducer' );
require( '../ui/test/selectors' );

describe( 'editor', () => {
describe( 'contact-form', () => {
Expand Down