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

Framework: Remove i18n mixin injections from tests #18471

Merged
merged 4 commits into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ jest.mock( 'lib/analytics', () => {} );
/**
* External dependencies
*/
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import assert from 'assert';
import sinon from 'sinon';
import { identity } from 'lodash';

/**
* Internal dependencies
*/
import { MappedDomain } from '../mapped-domain.jsx';

describe( 'mapped-domain', () => {
let React,
MappedDomain,
props,
TestUtils;
let props;

before( () => {
props = {
Expand All @@ -28,15 +32,6 @@ describe( 'mapped-domain', () => {
};
} );

before( () => {
React = require( 'react' );
TestUtils = require( 'react-addons-test-utils' );

const ReactClass = require( 'react/lib/ReactClass' );
ReactClass.injection.injectMixin( require( 'i18n-calypso' ).mixin );
MappedDomain = require( '../mapped-domain.jsx' ).MappedDomain;
} );

it( 'should render when props.domain.expirationMoment is null', () => {
const renderer = TestUtils.createRenderer();
renderer.render( <MappedDomain { ...props } /> );
Expand Down
34 changes: 12 additions & 22 deletions client/my-sites/domains/domain-management/list/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jest.mock( 'lib/wp', () => ( {
/**
* External dependencies
*/
import React from 'react';
import ReactDom from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import deepFreeze from 'deep-freeze';
import assert from 'assert';
import { Provider as ReduxProvider } from 'react-redux';
Expand All @@ -19,31 +22,18 @@ import { Provider as ReduxProvider } from 'react-redux';
import { createReduxStore } from 'state';
import { useSandbox } from 'test/helpers/use-sinon';

import {
PRIMARY_DOMAIN_CHANGE_SUCCESS,
PRIMARY_DOMAIN_CHANGE_FAIL,
} from '../constants';
import { List as DomainList } from '../';

describe( 'index', function() {
let React,
ReactDom,
ReactClass,
DomainList,
TestUtils,
noticeTypes,
component,
let component,
sandbox;

useSandbox( newSandbox => sandbox = newSandbox );

before( () => {
React = require( 'react' );
ReactDom = require( 'react-dom' );
TestUtils = require( 'react-addons-test-utils' );

noticeTypes = require( '../constants' );

ReactClass = require( 'react/lib/ReactClass' );
ReactClass.injection.injectMixin( require( 'i18n-calypso' ).mixin );

DomainList = require( '../' ).List;
} );

const selectedSite = deepFreeze( {
slug: 'example.com',
ID: 1
Expand Down Expand Up @@ -164,7 +154,7 @@ describe( 'index', function() {
setTimeout( () => {
assert( ! component.state.settingPrimaryDomain, 'Setting Primary Domain should be false' );
assert( ! component.changePrimaryDomainModeEnabled );
assert.equal( component.state.notice.type, noticeTypes.PRIMARY_DOMAIN_CHANGE_SUCCESS );
assert.equal( component.state.notice.type, PRIMARY_DOMAIN_CHANGE_SUCCESS );
assert.equal( component.state.notice.previousDomainName, defaultProps.domains.list[ 1 ].name );
done();
}, 0 );
Expand All @@ -177,7 +167,7 @@ describe( 'index', function() {
assert( ! component.state.settingPrimaryDomain );
assert( component.state.changePrimaryDomainModeEnabled );
assert.equal( component.state.primaryDomainIndex, 1 );
assert.equal( component.state.notice.type, noticeTypes.PRIMARY_DOMAIN_CHANGE_FAIL );
assert.equal( component.state.notice.type, PRIMARY_DOMAIN_CHANGE_FAIL );
done();
}, 0 );
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** @jest-environment jsdom */
jest.mock( 'my-sites/plugins/plugin-action/plugin-action', () => require( './mocks/plugin-action' ) );
jest.mock( 'lib/plugins/actions', () => require( './mocks/actions' ) );
jest.mock( 'matches-selector', () => require( 'component-matches-selector' ), { virtual: true } );
jest.mock( 'query', () => require( 'component-query' ), { virtual: true } );

/**
Expand Down
7 changes: 0 additions & 7 deletions client/my-sites/plugins/plugins-list/test/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jest.mock( 'lib/wp', () => ( {
} ) );
jest.mock( 'my-sites/plugins/plugin-item/plugin-item', () => require( 'components/empty-component' ) );
jest.mock( 'my-sites/plugins/plugin-list-header', () => require( 'components/empty-component' ) );
jest.mock( 'matches-selector', () => require( 'component-matches-selector' ), { virtual: true } );
jest.mock( 'query', () => require( 'component-query' ), { virtual: true } );

/**
Expand All @@ -34,12 +33,6 @@ import { PluginsList } from '../';
import { sites } from './fixtures';

describe( 'PluginsList', () => {
before( () => {
const ReactClass = require( 'react/lib/ReactClass' );

ReactClass.injection.injectMixin( require( 'i18n-calypso' ).mixin );
} );

describe( 'rendering bulk actions', function() {
let renderedPluginsList, plugins, props;

Expand Down
1 change: 0 additions & 1 deletion client/my-sites/theme/test/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jest.mock( 'lib/wp', () => ( {
getProducts: () => {}
} ),
} ) );
jest.mock( 'matches-selector', () => require( 'component-matches-selector' ), { virtual: true } );
jest.mock( 'my-sites/themes/theme-preview', () => require( 'components/empty-component' ) );
jest.mock( 'my-sites/themes/themes-site-selector-modal', () => require( 'components/empty-component' ) );

Expand Down
1 change: 0 additions & 1 deletion client/post-editor/test/post-editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jest.mock( 'lib/user', () => () => {} );
jest.mock( 'lib/wp', () => ( {
undocumented: () => {}
} ) );
jest.mock( 'matches-selector', () => require( 'component-matches-selector' ), { virtual: true } );
jest.mock( 'post-editor/editor-document-head', () => require( 'components/empty-component' ) );
jest.mock( 'post-editor/editor-action-bar', () => require( 'components/empty-component' ) );
jest.mock( 'post-editor/editor-drawer', () => require( 'components/empty-component' ) );
Expand Down