Skip to content
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 @@ -25,7 +25,7 @@ function compare(input, output) {

var oldEnv;

describe('dev-expression', function() {
describe('dev-expression', () => {
beforeEach(() => {
oldEnv = process.env.NODE_ENV;
process.env.NODE_ENV = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ var React;
var ReactComponentWithPureRenderMixin;
var ReactTestUtils;

describe('ReactComponentWithPureRenderMixin', function() {
describe('ReactComponentWithPureRenderMixin', () => {

beforeEach(function() {
beforeEach(() => {
React = require('React');
ReactComponentWithPureRenderMixin =
require('ReactComponentWithPureRenderMixin');
ReactTestUtils = require('ReactTestUtils');
});

it('provides a default shouldComponentUpdate implementation', function() {
it('provides a default shouldComponentUpdate implementation', () => {
var renderCalls = 0;
class PlasticWrap extends React.Component {
constructor(props, context) {
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('ReactComponentWithPureRenderMixin', function() {
expect(renderCalls).toBe(4);
});

it('does not do a deep comparison', function() {
it('does not do a deep comparison', () => {
function getInitialState() {
return {
foo: [1, 2, 3],
Expand Down
18 changes: 9 additions & 9 deletions src/addons/__tests__/ReactFragment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ var React;
var ReactDOM;
var ReactFragment;

describe('ReactFragment', function() {
describe('ReactFragment', () => {

beforeEach(function() {
beforeEach(() => {
React = require('React');
ReactDOM = require('ReactDOM');
ReactFragment = require('ReactFragment');
});

it('should throw if a plain object is used as a child', function() {
it('should throw if a plain object is used as a child', () => {
var children = {
x: <span />,
y: <span />,
Expand All @@ -39,7 +39,7 @@ describe('ReactFragment', function() {
);
});

it('should throw if a plain object even if it is in an owner', function() {
it('should throw if a plain object even if it is in an owner', () => {
class Foo extends React.Component {
render() {
var children = {
Expand All @@ -59,7 +59,7 @@ describe('ReactFragment', function() {
);
});

it('should throw if a plain object looks like an old element', function() {
it('should throw if a plain object looks like an old element', () => {
var oldEl = {_isReactElement: true, type: 'span', props: {}};
var container = document.createElement('div');
expect(() => ReactDOM.render(<div>{oldEl}</div>, container)).toThrowError(
Expand All @@ -70,7 +70,7 @@ describe('ReactFragment', function() {
);
});

it('warns for numeric keys on objects as children', function() {
it('warns for numeric keys on objects as children', () => {
spyOn(console, 'error');

ReactFragment.create({1: <span />, 2: <span />});
Expand All @@ -81,7 +81,7 @@ describe('ReactFragment', function() {
);
});

it('should warn if passing null to createFragment', function() {
it('should warn if passing null to createFragment', () => {
spyOn(console, 'error');
ReactFragment.create(null);
expect(console.error.calls.count()).toBe(1);
Expand All @@ -90,7 +90,7 @@ describe('ReactFragment', function() {
);
});

it('should warn if passing an array to createFragment', function() {
it('should warn if passing an array to createFragment', () => {
spyOn(console, 'error');
ReactFragment.create([]);
expect(console.error.calls.count()).toBe(1);
Expand All @@ -99,7 +99,7 @@ describe('ReactFragment', function() {
);
});

it('should warn if passing a ReactElement to createFragment', function() {
it('should warn if passing a ReactElement to createFragment', () => {
spyOn(console, 'error');
ReactFragment.create(<div />);
expect(console.error.calls.count()).toBe(1);
Expand Down
10 changes: 5 additions & 5 deletions src/addons/__tests__/renderSubtreeIntoContainer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ var ReactDOM = require('ReactDOM');
var ReactTestUtils = require('ReactTestUtils');
var renderSubtreeIntoContainer = require('renderSubtreeIntoContainer');

describe('renderSubtreeIntoContainer', function() {
describe('renderSubtreeIntoContainer', () => {

it('should pass context when rendering subtree elsewhere', function() {
it('should pass context when rendering subtree elsewhere', () => {
var portal = document.createElement('div');

class Component extends React.Component {
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('renderSubtreeIntoContainer', function() {
expect(portal.firstChild.innerHTML).toBe('bar');
});

it('should throw if parentComponent is invalid', function() {
it('should throw if parentComponent is invalid', () => {
var portal = document.createElement('div');

class Component extends React.Component {
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('renderSubtreeIntoContainer', function() {
}
});

it('should update context if it changes due to setState', function() {
it('should update context if it changes due to setState', () => {
var container = document.createElement('div');
document.body.appendChild(container);
var portal = document.createElement('div');
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('renderSubtreeIntoContainer', function() {
expect(portal.firstChild.innerHTML).toBe('changed-changed');
});

it('should update context if it changes due to re-render', function() {
it('should update context if it changes due to re-render', () => {
var container = document.createElement('div');
document.body.appendChild(container);
var portal = document.createElement('div');
Expand Down
62 changes: 31 additions & 31 deletions src/addons/__tests__/update-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,62 @@

var update = require('update');

describe('update', function() {
describe('update', () => {

describe('$push', function() {
it('pushes', function() {
describe('$push', () => {
it('pushes', () => {
expect(update([1], {$push: [7]})).toEqual([1, 7]);
});
it('does not mutate the original object', function() {
it('does not mutate the original object', () => {
var obj = [1];
update(obj, {$push: [7]});
expect(obj).toEqual([1]);
});
it('only pushes an array', function() {
it('only pushes an array', () => {
expect(update.bind(null, [], {$push: 7})).toThrowError(
'update(): expected spec of $push to be an array; got 7. Did you ' +
'forget to wrap your parameter in an array?'
);
});
it('only pushes unto an array', function() {
it('only pushes unto an array', () => {
expect(update.bind(null, 1, {$push: 7})).toThrowError(
'update(): expected target of $push to be an array; got 1.'
);
});
});

describe('$unshift', function() {
it('unshifts', function() {
describe('$unshift', () => {
it('unshifts', () => {
expect(update([1], {$unshift: [7]})).toEqual([7, 1]);
});
it('does not mutate the original object', function() {
it('does not mutate the original object', () => {
var obj = [1];
update(obj, {$unshift: [7]});
expect(obj).toEqual([1]);
});
it('only unshifts an array', function() {
it('only unshifts an array', () => {
expect(update.bind(null, [], {$unshift: 7})).toThrowError(
'update(): expected spec of $unshift to be an array; got 7. Did you ' +
'forget to wrap your parameter in an array?'
);
});
it('only unshifts unto an array', function() {
it('only unshifts unto an array', () => {
expect(update.bind(null, 1, {$unshift: 7})).toThrowError(
'update(): expected target of $unshift to be an array; got 1.'
);
});
});

describe('$splice', function() {
it('splices', function() {
describe('$splice', () => {
it('splices', () => {
expect(update([1, 4, 3], {$splice: [[1, 1, 2]]})).toEqual([1, 2, 3]);
});
it('does not mutate the original object', function() {
it('does not mutate the original object', () => {
var obj = [1, 4, 3];
update(obj, {$splice: [[1, 1, 2]]});
expect(obj).toEqual([1, 4, 3]);
});
it('only splices an array of arrays', function() {
it('only splices an array of arrays', () => {
expect(update.bind(null, [], {$splice: 1})).toThrowError(
'update(): expected spec of $splice to be an array of arrays; got 1. ' +
'Did you forget to wrap your parameters in an array?'
Expand All @@ -78,65 +78,65 @@ describe('update', function() {
'Did you forget to wrap your parameters in an array?'
);
});
it('only splices unto an array', function() {
it('only splices unto an array', () => {
expect(update.bind(null, 1, {$splice: 7})).toThrowError(
'Expected $splice target to be an array; got 1'
);
});
});

describe('$merge', function() {
it('merges', function() {
describe('$merge', () => {
it('merges', () => {
expect(update({a: 'b'}, {$merge: {c: 'd'}})).toEqual({a: 'b', c: 'd'});
});
it('does not mutate the original object', function() {
it('does not mutate the original object', () => {
var obj = {a: 'b'};
update(obj, {$merge: {c: 'd'}});
expect(obj).toEqual({a: 'b'});
});
it('only merges with an object', function() {
it('only merges with an object', () => {
expect(update.bind(null, {}, {$merge: 7})).toThrowError(
'update(): $merge expects a spec of type \'object\'; got 7'
);
});
it('only merges with an object', function() {
it('only merges with an object', () => {
expect(update.bind(null, 7, {$merge: {a: 'b'}})).toThrowError(
'update(): $merge expects a target of type \'object\'; got 7'
);
});
});

describe('$set', function() {
it('sets', function() {
describe('$set', () => {
it('sets', () => {
expect(update({a: 'b'}, {$set: {c: 'd'}})).toEqual({c: 'd'});
});
it('does not mutate the original object', function() {
it('does not mutate the original object', () => {
var obj = {a: 'b'};
update(obj, {$set: {c: 'd'}});
expect(obj).toEqual({a: 'b'});
});
});

describe('$apply', function() {
describe('$apply', () => {
var applier = function(node) {
return {v: node.v * 2};
};
it('applies', function() {
it('applies', () => {
expect(update({v: 2}, {$apply: applier})).toEqual({v: 4});
});
it('does not mutate the original object', function() {
it('does not mutate the original object', () => {
var obj = {v: 2};
update(obj, {$apply: applier});
expect(obj).toEqual({v: 2});
});
it('only applies a function', function() {
it('only applies a function', () => {
expect(update.bind(null, 2, {$apply: 123})).toThrowError(
'update(): expected spec of $apply to be a function; got 123.'
);
});
});

it('should support deep updates', function() {
it('should support deep updates', () => {
expect(update({
a: 'b',
c: {
Expand Down Expand Up @@ -169,15 +169,15 @@ describe('update', function() {
});
});

it('should require a command', function() {
it('should require a command', () => {
expect(update.bind(null, {a: 'b'}, {a: 'c'})).toThrowError(
'update(): You provided a key path to update() that did not contain ' +
'one of $push, $unshift, $splice, $set, $merge, $apply. Did you ' +
'forget to include {$set: ...}?'
);
});

it('should perform safe hasOwnProperty check', function() {
it('should perform safe hasOwnProperty check', () => {
expect(update({}, {'hasOwnProperty': {$set: 'a'}})).toEqual({
'hasOwnProperty': 'a',
});
Expand Down
6 changes: 3 additions & 3 deletions src/addons/link/__tests__/LinkedStateMixin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
'use strict';


describe('LinkedStateMixin', function() {
describe('LinkedStateMixin', () => {
var LinkedStateMixin;
var React;
var ReactTestUtils;

beforeEach(function() {
beforeEach(() => {
LinkedStateMixin = require('LinkedStateMixin');
React = require('React');
ReactTestUtils = require('ReactTestUtils');
});

it('should create a ReactLink for state', function() {
it('should create a ReactLink for state', () => {
var Component = React.createClass({
mixins: [LinkedStateMixin],

Expand Down
Loading