Skip to content

Commit

Permalink
Merge pull request #3773 from Automattic/update/redux-single-test-runner
Browse files Browse the repository at this point in the history
State: Remove subtree Makefiles in favor of single test runner
  • Loading branch information
aduth committed Mar 4, 2016
2 parents 05a4c88 + bc0576c commit e28400e
Show file tree
Hide file tree
Showing 34 changed files with 216 additions and 318 deletions.
10 changes: 10 additions & 0 deletions client/lib/react-test-env-setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ module.exports = function( markup, features ) {
global.XMLHttpRequest = window.XMLHttpRequest;
}
};

module.exports.cleanup = function() {
delete global.document;
delete global.window;
delete global.navigator;
delete global.Element;
delete global.history;
delete global.localStorage;
delete global.XMLHttpRequest;
};
7 changes: 5 additions & 2 deletions client/state/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ BASE_DIR := $(NODE_BIN)/../..
NODE_PATH := $(BASE_DIR)/client

test:
@NODE_ENV=test NODE_PATH=$(NODE_PATH) $(MOCHA) --compilers jsx:babel/register,js:babel/register --reporter $(REPORTER)
@NODE_ENV=test NODE_PATH=$(NODE_PATH) $(MOCHA) --compilers jsx:babel/register,js:babel/register --reporter $(REPORTER) $(addprefix --grep ,$(GREP))

.PHONY: test
test-%:
@GREP="state $*" make test

.PHONY: test test-%
10 changes: 0 additions & 10 deletions client/state/application/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions client/state/comments/Makefile

This file was deleted.

11 changes: 1 addition & 10 deletions client/state/comments/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
*/
import nock from 'nock';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import Chai, { expect } from 'chai';
import { expect } from 'chai';
import Immutable from 'immutable';

/**
Expand Down Expand Up @@ -34,8 +33,6 @@ import {
NUMBER_OF_COMMENTS_PER_FETCH
} from '../constants'

Chai.use( sinonChai );

const MANY_COMMENTS_POST = {
siteId: 91750058,
postId: 287
Expand All @@ -44,14 +41,8 @@ const MANY_COMMENTS_POST = {
const API_DOMAIN = 'https://public-api.wordpress.com:443';

describe( 'actions', () => {
before( () => {
// make sure all requests are mocked
nock.disableNetConnect();
} );

after( () => {
nock.cleanAll();
nock.enableNetConnect();
} );

describe( '#receivePost()', () => {
Expand Down
10 changes: 0 additions & 10 deletions client/state/current-user/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions client/state/notices/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions client/state/plugins/wporg/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions client/state/plugins/wporg/test/test-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe( 'WPorg Data Actions', function() {
} );

after( function() {
mockery.deregisterAll();
mockery.disable();
} );

Expand Down
10 changes: 0 additions & 10 deletions client/state/post-types/Makefile

This file was deleted.

13 changes: 2 additions & 11 deletions client/state/post-types/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
*/
import nock from 'nock';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import Chai, { expect } from 'chai';
import { expect } from 'chai';

/**
* Internal dependencies
Expand All @@ -23,16 +22,12 @@ import {
describe( 'actions', () => {
const spy = sinon.spy();

before( () => {
Chai.use( sinonChai );
} );

beforeEach( () => {
spy.reset();
} );

after( () => {
nock.restore();
nock.cleanAll();
} );

describe( '#receivePostTypes()', () => {
Expand Down Expand Up @@ -68,10 +63,6 @@ describe( 'actions', () => {
} );
} );

after( () => {
nock.cleanAll();
} );

it( 'should dispatch fetch action when thunk triggered', () => {
requestPostTypes( 2916284 )( spy );

Expand Down
4 changes: 1 addition & 3 deletions client/state/post-types/test/reducer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/**
* External dependencies
*/
import Chai, { expect } from 'chai';
import { expect } from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import deepFreeze from 'deep-freeze';

/**
Expand All @@ -21,7 +20,6 @@ import { requesting, items } from '../reducer';

describe( 'reducer', () => {
before( () => {
Chai.use( sinonChai );
sinon.stub( console, 'warn' );
} );

Expand Down
10 changes: 0 additions & 10 deletions client/state/posts/Makefile

This file was deleted.

21 changes: 2 additions & 19 deletions client/state/posts/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
*/
import nock from 'nock';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import Chai, { expect } from 'chai';
import { expect } from 'chai';

/**
* Internal dependencies
Expand All @@ -31,16 +30,12 @@ import {
describe( 'actions', () => {
const spy = sinon.spy();

before( () => {
Chai.use( sinonChai );
} );

beforeEach( () => {
spy.reset();
} );

after( () => {
nock.restore();
nock.cleanAll();
} );

describe( '#receivePost()', () => {
Expand Down Expand Up @@ -92,10 +87,6 @@ describe( 'actions', () => {
} );
} );

after( () => {
nock.cleanAll();
} );

it( 'should dispatch fetch action when thunk triggered', () => {
requestSitePosts( 2916284 )( spy );

Expand Down Expand Up @@ -173,10 +164,6 @@ describe( 'actions', () => {
} );
} );

after( () => {
nock.cleanAll();
} );

it( 'should dispatch posts receive action when request completes', () => {
return requestPosts()( spy ).then( () => {
expect( spy ).to.have.been.calledWith( {
Expand All @@ -203,10 +190,6 @@ describe( 'actions', () => {
} );
} );

after( () => {
nock.cleanAll();
} );

it( 'should dispatch request action when thunk triggered', () => {
requestSitePost( 2916284, 413 )( spy );

Expand Down
10 changes: 0 additions & 10 deletions client/state/receipts/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions client/state/sharing/publicize/Makefile

This file was deleted.

10 changes: 2 additions & 8 deletions client/state/sharing/publicize/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
*/
import nock from 'nock';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import Chai, { expect } from 'chai';
import { expect } from 'chai';

/**
* Internal dependencies
Expand All @@ -20,11 +19,6 @@ import {
failConnectionsRequest
} from '../actions';

/**
* Test setup
*/
Chai.use( sinonChai );

describe( '#fetchConnections()', () => {
const spy = sinon.spy();

Expand All @@ -49,7 +43,7 @@ describe( '#fetchConnections()', () => {
} );

after( () => {
nock.restore();
nock.cleanAll();
} );

it( 'should dispatch fetch action when thunk triggered', () => {
Expand Down
10 changes: 0 additions & 10 deletions client/state/site-settings/exporter/Makefile

This file was deleted.

10 changes: 2 additions & 8 deletions client/state/site-settings/exporter/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
*/
import nock from 'nock';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import Chai, { expect } from 'chai';
import { expect } from 'chai';

/**
* Internal dependencies
Expand Down Expand Up @@ -32,11 +31,6 @@ import {
SAMPLE_EXPORT_FAILED_RESPONSE,
} from './sample-data';

/**
* Test setup
*/
Chai.use( sinonChai );

describe( 'actions', () => {
const spy = sinon.spy();
const getState = () => ( {
Expand All @@ -63,7 +57,7 @@ describe( 'actions', () => {
} );

after( () => {
nock.restore();
nock.cleanAll();
} );

describe( '#advancedSettingsFetch()', () => {
Expand Down
10 changes: 0 additions & 10 deletions client/state/sites/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions client/state/sites/plans/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions client/state/support/Makefile

This file was deleted.

Loading

0 comments on commit e28400e

Please sign in to comment.