Skip to content

Commit

Permalink
No longer deep clone fixture in every test #15
Browse files Browse the repository at this point in the history
Was destroying unserializable members
  • Loading branch information
ovidiuch committed Jun 7, 2015
1 parent 020b4f8 commit 97e0401
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 44 deletions.
4 changes: 2 additions & 2 deletions tests/components/component-playground/default/events/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ describe(`ComponentPlayground (${FIXTURE}) Events DOM`, function() {
var React = require('react/addons'),
utils = React.addons.TestUtils,
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should mark expanded component on click', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var FIXTURE = 'default';
describe(`ComponentPlayground (${FIXTURE}) Events Handlers`, function() {
var ComponentTree = require('react-component-tree'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));

sinon.spy(component, 'setState');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe(`ComponentPlayground (${FIXTURE}) Render Children`, function() {
var loadChild = require('react-component-tree').loadChild,
render = require('tests/lib/render-component.js'),
stubLoadChild = require('tests/setup/stub-load-child.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
Expand All @@ -14,7 +14,7 @@ describe(`ComponentPlayground (${FIXTURE}) Render Children`, function() {
stubLoadChild();

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should not load preview component', function() {
Expand Down
4 changes: 2 additions & 2 deletions tests/components/component-playground/default/render/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var FIXTURE = 'default';
describe(`ComponentPlayground (${FIXTURE}) Render DOM`, function() {
var $ = require('jquery'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should render cosmos plug', function() {
Expand Down
4 changes: 2 additions & 2 deletions tests/components/component-playground/default/render/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var FIXTURE = 'default';
describe(`ComponentPlayground (${FIXTURE}) Render URLs`, function() {
var render = require('tests/lib/render-component.js'),
getUrlProps = require('tests/lib/get-url-props.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should generate urls with component and fixture names', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var FIXTURE = 'default';
describe(`ComponentPlayground (${FIXTURE}) Transitions Mount`, function() {
var React = require('react'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
Expand All @@ -16,7 +16,7 @@ describe(`ComponentPlayground (${FIXTURE}) Transitions Mount`, function() {
sinon.stub(window, 'setInterval').returns(timeoutId);
sinon.stub(window, 'clearInterval');

({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

afterEach(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ var FIXTURE = 'full-screen';

describe(`ComponentPlayground (${FIXTURE}) Render DOM`, function() {
var render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should add full-screen class', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var FIXTURE = 'selected-fixture-and-editor-focused';
describe(`ComponentPlayground (${FIXTURE}) Events Handlers`, function() {
var ComponentTree = require('react-component-tree'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));

sinon.spy(component, 'setState');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ describe(`ComponentPlayground (${FIXTURE}) Events DOM`, function() {
var React = require('react/addons'),
utils = React.addons.TestUtils,
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should focus on editor on fixture click', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var FIXTURE = 'selected-fixture-and-editor';
describe(`ComponentPlayground (${FIXTURE}) Events Handlers`, function() {
var ComponentTree = require('react-component-tree'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

define('on fixture update', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var FIXTURE = 'selected-fixture-and-editor';
describe(`ComponentPlayground (${FIXTURE}) Render DOM`, function() {
var $ = require('jquery'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should render fixture editor', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var FIXTURE = 'selected-fixture-and-editor';
describe(`ComponentPlayground (${FIXTURE}) Render URLs`, function() {
var render = require('tests/lib/render-component.js'),
getUrlProps = require('tests/lib/get-url-props.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should generate close fixture editor url', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ describe(`ComponentPlayground (${FIXTURE}) Events DOM`, function() {
utils = React.addons.TestUtils,
_ = require('lodash'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

var stubbedFixture = _.assign({}, originalFixture, {
var stubbedFixture = _.assign({}, fixture, {
router: {
goTo: sinon.spy(),
routeLink: sinon.spy()
}
});

beforeEach(function() {
({fixture, container, component, $component} = render(stubbedFixture));
({container, component, $component} = render(stubbedFixture));
});

afterEach(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe(`ComponentPlayground (${FIXTURE}) Render Children`, function() {
var loadChild = require('react-component-tree').loadChild,
render = require('tests/lib/render-component.js'),
stubLoadChild = require('tests/setup/stub-load-child.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
Expand All @@ -15,7 +15,7 @@ describe(`ComponentPlayground (${FIXTURE}) Render Children`, function() {
stubLoadChild();

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));

childParams = component.children.preview.call(component);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var FIXTURE = 'selected-fixture';
describe(`ComponentPlayground (${FIXTURE}) Render DOM`, function() {
var $ = require('jquery'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should not render cosmos plug', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var FIXTURE = 'selected-fixture';
describe(`ComponentPlayground (${FIXTURE}) Render URLs`, function() {
var render = require('tests/lib/render-component.js'),
getUrlProps = require('tests/lib/get-url-props.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
container,
fixture;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should generate open full-screen url', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var FIXTURE = 'selected-fixture';
describe(`ComponentPlayground (${FIXTURE}) Transitions Mount`, function() {
var ComponentTree = require('react-component-tree'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
Expand All @@ -12,12 +12,12 @@ describe(`ComponentPlayground (${FIXTURE}) Transitions Mount`, function() {

// The following tests are about the initial state generation, so we don't
// want it included in the fixture
var statelessFixture = _.omit(originalFixture, 'state');
var statelessFixture = _.omit(fixture, 'state');

beforeEach(function() {
sinon.stub(ComponentTree, 'injectState');

({fixture, container, component, $component} = render(statelessFixture));
({container, component, $component} = render(statelessFixture));
});

afterEach(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var FIXTURE = 'selected-fixture';
describe(`ComponentPlayground (${FIXTURE}) Transitions Props`, function() {
var ComponentTree = require('react-component-tree'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
Expand All @@ -13,7 +13,7 @@ describe(`ComponentPlayground (${FIXTURE}) Transitions Props`, function() {
stateInjected;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));

sinon.stub(ComponentTree, 'injectState');
sinon.spy(component, 'setState');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe(`ComponentPlayground (${FIXTURE}) Transitions State`, function() {
_ = require('lodash'),
ComponentTree = require('react-component-tree'),
render = require('tests/lib/render-component.js'),
originalFixture = require(`fixtures/component-playground/${FIXTURE}.js`);
fixture = require(`fixtures/component-playground/${FIXTURE}.js`);

var component,
$component,
Expand All @@ -14,7 +14,7 @@ describe(`ComponentPlayground (${FIXTURE}) Transitions State`, function() {
stateInjected;

beforeEach(function() {
({fixture, container, component, $component} = render(originalFixture));
({container, component, $component} = render(fixture));
});

it('should inject preview state when fixture changes', function() {
Expand Down
6 changes: 2 additions & 4 deletions tests/lib/render-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ var $ = require('jquery'),
ComponentTree = require('react-component-tree'),
ComponentPlayground = require('components/component-playground.jsx');

module.exports = function(originalFixture) {
var fixture = _.cloneDeep(originalFixture),
container = document.createElement('div'),
module.exports = function(fixture) {
var container = document.createElement('div'),
component,
$component;

Expand All @@ -17,7 +16,6 @@ module.exports = function(originalFixture) {
$component = $(component.getDOMNode());

return {
fixture: fixture,
container: container,
component: component,
$component: $component
Expand Down

0 comments on commit 97e0401

Please sign in to comment.