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
7 changes: 7 additions & 0 deletions src/load-child-mixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var loadChild = require('./load-child.js');

module.exports = {
loadChild: function(childName, a, b, c, d, e, f) {
return loadChild.loadChild(this.children, childName, a, b, c, d, e, f);
}
};
2 changes: 1 addition & 1 deletion src/load-child.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var _ = require('lodash'),
React = require('react');

module.exports = function(childTemplates, childName, a, b, c, d, e, f) {
exports.loadChild = function(childTemplates, childName, a, b, c, d, e, f) {
/**
* Create a React element for a specific child type.
*
Expand Down
3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
Mixin: require('./load-child-mixin.js')
};
34 changes: 34 additions & 0 deletions tests/load-child-mixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var _ = require('lodash'),
loadChild = require('../src/load-child.js'),
Mixin = require('../src/load-child-mixin.js');

describe('Load child mixin', function() {
var fakeReactElement = {},
fakeComponent;

beforeEach(function() {
sinon.stub(loadChild, 'loadChild').returns(fakeReactElement);

fakeComponent = _.clone(Mixin);
fakeComponent.children = {};
});

afterEach(function() {
loadChild.loadChild.restore();
});

it('should call loadChild lib with same args', function() {
fakeComponent.loadChild('myChild', 5, 10, true);

var args = loadChild.loadChild.lastCall.args;
expect(args[0]).to.equal(fakeComponent.children);
expect(args[1]).to.equal('myChild');
expect(args[2]).to.equal(5);
expect(args[3]).to.equal(10);
expect(args[4]).to.equal(true);
});

it('should return what loadChild lib returned', function() {
expect(fakeComponent.loadChild()).to.equal(fakeReactElement);
});
});
4 changes: 2 additions & 2 deletions tests/load-child.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var React = require('react'),
loadChild = require('../src/load-child.js');
loadChild = require('../src/load-child.js').loadChild;

describe('Loading children', function() {
describe('Load child', function() {
var FirstComponent = {},
SecondComponent = {},
childTemplates;
Expand Down
4 changes: 2 additions & 2 deletions tests/load-missing-child.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var React = require('react'),
loadChild = require('../src/load-child.js');
loadChild = require('../src/load-child.js').loadChild;

describe('Loading missing child', function() {
describe('Load missing child', function() {
var childTemplates;

beforeEach(function() {
Expand Down