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

Tests: Move Spectrum related tests to single test runner #3978

Merged
merged 5 commits into from
Mar 11, 2016
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
@@ -1,24 +1,22 @@
require( 'lib/react-test-env-setup' )();

/**
* External Dependencies
*/
var sinon = require( 'sinon' ),
sinonChai = require( 'sinon-chai' ),
ReactDom = require( 'react-dom' ),
React = require( 'react' ),
TestUtils = require( 'react-addons-test-utils' ),
chai = require( 'chai' );
import { expect } from 'chai';
import sinon from 'sinon';
import ReactDom from 'react-dom';
import React from 'react';
import TestUtils from 'react-addons-test-utils';

/**
* Internal Dependencies
*/
var DomainSuggestion = require( 'components/domains/domain-suggestion' ),
DomainProductPrice = require( 'components/domains/domain-product-price' );

chai.use( sinonChai );
import DomainSuggestion from 'components/domains/domain-suggestion';
import DomainProductPrice from 'components/domains/domain-product-price';
import useFakeDom from 'test/helpers/use-fake-dom';

describe( 'Domain Suggestion', function() {
useFakeDom();

beforeEach( function() {
DomainSuggestion.prototype.__reactAutoBindMap.translate = sinon.stub();
DomainProductPrice.prototype.__reactAutoBindMap.translate = sinon.stub();
Expand All @@ -31,17 +29,17 @@ describe( 'Domain Suggestion', function() {

describe( 'added domain', function() {
it( 'should show a checkbox when in cart', function() {
var suggestionComponent = TestUtils.renderIntoDocument( <DomainSuggestion isAdded={true} /> );
var suggestionComponent = TestUtils.renderIntoDocument( <DomainSuggestion isAdded={ true } /> );

chai.expect( suggestionComponent.refs.checkmark ).to.exist;
expect( suggestionComponent.refs.checkmark ).to.exist;
} );

it( 'should show the button label when not in cart', function() {
var buttonLabel = 'Hello',
suggestionComponent = TestUtils.renderIntoDocument(
<DomainSuggestion isAdded={false} buttonLabel={buttonLabel} />
<DomainSuggestion isAdded={ false } buttonLabel={ buttonLabel } />
);
chai.expect( ReactDom.findDOMNode( suggestionComponent.refs.button ).textContent ).to.equal( buttonLabel );
expect( ReactDom.findDOMNode( suggestionComponent.refs.button ).textContent ).to.equal( buttonLabel );
} );
} );
} );
14 changes: 0 additions & 14 deletions client/lib/cart-values/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
/**
* External dependencies
*/
var assert = require( 'assert' );
import assert from 'assert';
import flow from 'lodash/flow';

/**
* Internal dependencies
*/
var cartValues = require( '../' ),
cartItems = cartValues.cartItems,
flow = require( 'lodash/flow' );
import useFilesystemMocks from 'test/helpers/use-filesystem-mocks';

var TEST_BLOG_ID = 1,
PREMIUM_PRODUCT = cartItems.premiumPlan( 'value_bundle', { isFreeTrial: false } ),
THEME_PRODUCT = cartItems.themeItem( 'mood' ),
DOMAIN_REGISTRATION_PRODUCT = cartItems.domainRegistration( { productSlug: 'dotcom_domain' } );
describe( 'index', function() {
const TEST_BLOG_ID = 1;
let cartItems, cartValues, DOMAIN_REGISTRATION_PRODUCT, PREMIUM_PRODUCT, THEME_PRODUCT;

useFilesystemMocks( __dirname );

before( () => {
cartValues = require( 'lib/cart-values' );
cartItems = cartValues.cartItems;
DOMAIN_REGISTRATION_PRODUCT = cartItems.domainRegistration( { productSlug: 'dotcom_domain' } );
PREMIUM_PRODUCT = cartItems.premiumPlan( 'value_bundle', { isFreeTrial: false } );
THEME_PRODUCT = cartItems.themeItem( 'mood' );
} );

describe( 'cart-values', function() {
describe( 'cart change functions', function() {
describe( 'flow( changeFunctions... )', function() {
it( 'should combine multiple cart operations into a single step', function() {
Expand Down
15 changes: 0 additions & 15 deletions client/lib/cart/store/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
var CartSynchronizer = require( '../cart-synchronizer' ),
FakeWPCOM = require( './fake-wpcom' ),
cartValues = require( 'lib/cart-values' ),
emptyCart = cartValues.emptyCart,
applyCoupon = cartValues.applyCoupon,
assert = require( 'assert' );
/**
* External dependencies
*/
import assert from 'assert';

/**
* Internal dependencies
*/
import CartSynchronizer from '../cart-synchronizer';
import FakeWPCOM from './fake-wpcom';
import useFilesystemMocks from 'test/helpers/use-filesystem-mocks';

var TEST_SITE_ID = 91234567890;

var poller = {
add: function() {}
};

describe( 'CartSynchronizer', function() {
describe( 'cart-synchronizer', function() {
let applyCoupon, emptyCart;

useFilesystemMocks( __dirname );

before( () => {
const cartValues = require( 'lib/cart-values' );

applyCoupon = cartValues.applyCoupon;
emptyCart = cartValues.emptyCart;
} );

describe( '*before* the first fetch from the server', function() {
it( 'should *not* allow the value to be read', function() {
var wpcom = FakeWPCOM(),
synchronizer = CartSynchronizer( TEST_SITE_ID, wpcom, poller );

assert.throws(function() { synchronizer.getLatestValue(); }, Error);
assert.throws( () => {
synchronizer.getLatestValue();
}, Error );
} );

it( 'should enqueue local changes and POST them after fetching', function() {
Expand All @@ -28,7 +46,9 @@ describe( 'CartSynchronizer', function() {
synchronizer.fetch();
synchronizer.update( applyCoupon( 'foo' ) );

assert.throws( function() { synchronizer.getLatestValue(); }, Error );
assert.throws( () => {
synchronizer.getLatestValue();
}, Error );
wpcom.resolveRequest( 0, serverCart );

assert.equal( synchronizer.getLatestValue().coupon, 'foo' );
Expand Down
14 changes: 0 additions & 14 deletions client/lib/credit-card-details/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ var assert = require( 'assert' );
var creditCardDetails = require( '../' );

function getRandomInt( min, max ) {
return Math.floor(Math.random() * (max - min + 1)) + min;
return Math.floor( Math.random() * ( max - min + 1 ) ) + min;
}

describe( 'credit-card-details', function() {
describe( 'index', function() {
describe( 'Validation', function() {
describe( 'Discover Card: range 622126-622925', function() {
const randomNumberBetweenRange = getRandomInt( 622126, 622925 ).toString();

it( 'should return null for 622125', function() {
assert.equal( null, creditCardDetails.getCreditCardType( '622125' ) );
} );
Expand All @@ -23,7 +25,6 @@ describe( 'credit-card-details', function() {
assert.equal( 'discover', creditCardDetails.getCreditCardType( '622126' ) );
} );

var randomNumberBetweenRange = getRandomInt(622126, 622925).toString();
it( 'should return `discover` for ' + randomNumberBetweenRange + ' (a random number between 622126 and 622925)', function() {
assert.equal( 'discover', creditCardDetails.getCreditCardType( randomNumberBetweenRange ) );
} );
Expand Down
12 changes: 0 additions & 12 deletions client/lib/network-connection/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
/**
* External dependencies
*/
var chai = require( 'chai' ),
expect = chai.expect,
sinon = require( 'sinon' ),
sinonChai = require( 'sinon-chai' );
import { expect } from 'chai';
import sinon from 'sinon';

/**
* Internal dependencies
*/
var config = require( 'config' ),
NetworkConnectionApp = require( 'lib/network-connection' );
import config from 'config';
import NetworkConnectionApp from 'lib/network-connection';

chai.use( sinonChai );

describe( 'Network connection', function() {
describe( 'index', function() {
beforeEach( function() {
this.configStub = sinon.stub( config, 'isEnabled' ).returns( true );
} );
Expand Down
12 changes: 0 additions & 12 deletions client/lib/plans-list/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var plans = [
[
{
"product_id":1003,
"product_name":"WordPress.com Premium",
Expand Down Expand Up @@ -99,6 +99,4 @@ var plans = [
"bill_period_label":"for life",
"price":"$0"
}
];

exports.plans = plans;
]
46 changes: 46 additions & 0 deletions client/lib/plans-list/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* External dependencies
*/
import assert from 'assert';

/**
* Internal dependencies
*/
import useFakeDom from 'test/helpers/use-fake-dom';
import useFilesystemMocks from 'test/helpers/use-filesystem-mocks';

describe( 'PlansList', function() {
const plansMockedData = require( './data/index.json' );
let PlansList;

useFakeDom();
useFilesystemMocks( __dirname );

before( () => {
PlansList = require( 'lib/plans-list' )
} );

describe( 'initialize', function() {
it( 'should populate the list of plans', function() {
const plansList = PlansList();

plansList.initialize( plansMockedData );

assert.strictEqual( plansList.get().length, plansMockedData.length );
} );

it( 'should set attributes properly', function() {
const plansList = PlansList();

plansList.initialize( plansMockedData );

const premiumPlan = plansList.get().filter( function( plan ) {
return plan.product_id === 1003;
} );

for ( let prop in premiumPlan ) {
assert.strictEqual( premiumPlan[ prop ], plansMockedData[ prop ] );
}
} );
} );
} );
31 changes: 0 additions & 31 deletions client/lib/plans-list/test/test.js

This file was deleted.

7 changes: 0 additions & 7 deletions client/my-sites/upgrades/cart/Makefile

This file was deleted.

Loading