react-outlet
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -0,1 +1,7 @@ | ||
2016-03-12 Version 1.0.3 | ||
* Cleaned up tests | ||
* Tested against React 14.x | ||
* More anal linting | ||
2015-07-13 Version 1.0.2 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "react-outlet", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Transclusion helpers for React.js", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "./node_modules/.bin/jshint src && ./node_modules/.bin/jest" | ||
"test": "eslint src spec && jest" | ||
}, | ||
@@ -29,10 +29,18 @@ "repository": { | ||
"devDependencies": { | ||
"babel-eslint": "^5.0.0", | ||
"babel-jest": "^9.0.3", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-react": "^6.5.0", | ||
"eslint": "2.2.0", | ||
"eslint-plugin-react": "^4.2.1", | ||
"jasmine-core": "^2.1.3", | ||
"jest-cli": "^0.2.2", | ||
"jest-cli": "^0.9.2", | ||
"jshint": "^2.6.0", | ||
"react": "^0", | ||
"react-tools": "^0.12.2" | ||
"react-addons-test-utils": "^0", | ||
"react-dom": "^0" | ||
}, | ||
"peerDependencies": { | ||
"react": "0.x" | ||
"react": "^0", | ||
"react-dom": "^0" | ||
}, | ||
@@ -44,5 +52,4 @@ "jest": { | ||
"object-assign" | ||
], | ||
"scriptPreprocessor": "<rootDir>/.jest-pre.js" | ||
] | ||
} | ||
} |
# Transclusion helpers for React.js | ||
![Travis.ci test status](https://travis-ci.org/carlsverre/react-outlet.svg) | ||
[![Travis.ci test status](https://travis-ci.org/carlsverre/react-outlet.svg)](https://travis-ci.org/carlsverre/react-outlet) | ||
@@ -5,0 +5,0 @@ ``` |
jest.autoMockOff(); | ||
describe('react-outlet', function() { | ||
var React, TestUtils; | ||
describe("react-outlet", function() { | ||
var React = require("react"); | ||
var ReactDOM = require("react-dom"); | ||
var TestUtils = require("react-addons-test-utils"); | ||
var Outlet, Plug, outlet_registry; | ||
beforeEach(function() { | ||
React = require('react/addons'); | ||
TestUtils = React.addons.TestUtils; | ||
var TestDiv = React.createClass({ | ||
propTypes: { | ||
children: React.PropTypes.node | ||
}, | ||
Outlet = require('../src/outlet'); | ||
Plug = require('../src/plug'); | ||
outlet_registry = require('../src/outlet_registry'); | ||
render: function() { | ||
return <div>{this.props.children}</div>; | ||
} | ||
}); | ||
beforeEach(function() { | ||
Outlet = require("../src/outlet"); | ||
Plug = require("../src/plug"); | ||
outlet_registry = require("../src/outlet_registry"); | ||
}); | ||
describe("Outlet", function() { | ||
@@ -26,13 +36,13 @@ it("supports generating an unique id", function() { | ||
var tree = TestUtils.renderIntoDocument( | ||
<div> | ||
<TestDiv> | ||
<Outlet outletId={ id } className="outlet-content" /> | ||
<Plug outletId={ id }>winner</Plug> | ||
</div> | ||
</TestDiv> | ||
); | ||
var outlet_content = TestUtils.findRenderedDOMComponentWithClass(tree, "outlet-content"); | ||
expect(outlet_content.getDOMNode().textContent).toEqual('winner'); | ||
expect(ReactDOM.findDOMNode(outlet_content).textContent).toEqual("winner"); | ||
var plug = TestUtils.findRenderedComponentWithType(tree, Plug); | ||
expect(plug.getDOMNode()).toBeNull(); | ||
expect(ReactDOM.findDOMNode(plug)).toBeNull(); | ||
}); | ||
@@ -44,2 +54,4 @@ | ||
var PlugWrap = React.createClass({ | ||
propTypes: { outletId: React.PropTypes.string }, | ||
getInitialState: function() { return { content: undefined, renderPlug: false }; }, | ||
@@ -57,6 +69,6 @@ | ||
var tree = TestUtils.renderIntoDocument( | ||
<div> | ||
<TestDiv> | ||
<Outlet outletId={ id } className="outlet-content" /> | ||
<PlugWrap outletId={ id } /> | ||
</div> | ||
</TestDiv> | ||
); | ||
@@ -80,3 +92,3 @@ | ||
expect(outlet_content.getDOMNode().textContent).toBe("foobar"); | ||
expect(ReactDOM.findDOMNode(outlet_content).textContent).toBe("foobar"); | ||
@@ -91,3 +103,3 @@ plug_wrap.setState({ content: undefined }); | ||
outlet_content = TestUtils.findRenderedDOMComponentWithClass(tree, "outlet-content"); | ||
expect(outlet_content.getDOMNode().textContent).toBe("testing"); | ||
expect(ReactDOM.findDOMNode(outlet_content).textContent).toBe("testing"); | ||
@@ -105,2 +117,3 @@ plug_wrap.setState({ renderPlug: false }); | ||
var PlugWrap = React.createClass({ | ||
propTypes: { outletId: React.PropTypes.string }, | ||
getInitialState: function() { return { content: undefined }; }, | ||
@@ -124,3 +137,3 @@ | ||
var outlet_content = TestUtils.findRenderedDOMComponentWithClass(tree2, "outlet-content"); | ||
expect(outlet_content.getDOMNode().textContent).toBe("foobar"); | ||
expect(ReactDOM.findDOMNode(outlet_content).textContent).toBe("foobar"); | ||
@@ -139,3 +152,3 @@ plug_wrap.setState({ content: undefined }); | ||
var tree = TestUtils.renderIntoDocument( | ||
<div> | ||
<TestDiv> | ||
<Outlet outletId={ id } className="outlet-first" /> | ||
@@ -145,13 +158,12 @@ <Plug outletId={ id }>first</Plug> | ||
<Outlet outletId={ id2 } className="outlet-second" /> | ||
</div> | ||
</TestDiv> | ||
); | ||
expect(TestUtils | ||
.findRenderedDOMComponentWithClass(tree, "outlet-first") | ||
.getDOMNode() | ||
.textContent).toBe("first"); | ||
expect(TestUtils | ||
.findRenderedDOMComponentWithClass(tree, "outlet-second") | ||
.getDOMNode() | ||
.textContent).toBe("second"); | ||
expect(ReactDOM.findDOMNode( | ||
TestUtils.findRenderedDOMComponentWithClass(tree, "outlet-first") | ||
).textContent).toBe("first"); | ||
expect(ReactDOM.findDOMNode( | ||
TestUtils.findRenderedDOMComponentWithClass(tree, "outlet-second") | ||
).textContent).toBe("second"); | ||
}); | ||
@@ -164,6 +176,6 @@ | ||
TestUtils.renderIntoDocument( | ||
<div> | ||
<TestDiv> | ||
<Outlet outletId={ id } /> | ||
<Outlet outletId={ id } /> | ||
</div> | ||
</TestDiv> | ||
); | ||
@@ -179,3 +191,3 @@ }; | ||
var tree = React.render(<Outlet outletId={ id } />, container); | ||
ReactDOM.render(<Outlet outletId={ id } />, container); | ||
@@ -186,3 +198,3 @@ // ensure that the outlet registered itself | ||
// cause the tree to be unmounted | ||
expect(React.unmountComponentAtNode(container)).toBeTruthy(); | ||
expect(ReactDOM.unmountComponentAtNode(container)).toBeTruthy(); | ||
@@ -199,3 +211,3 @@ // ensure that the outlet unregistered itself | ||
// outlet is rendered in one tree | ||
var outlet_tree = React.render(<Outlet outletId={ id } />, container); | ||
ReactDOM.render(<Outlet outletId={ id } />, container); | ||
@@ -206,3 +218,3 @@ expect(outlet_registry.outlets.hasOwnProperty(id)).toBeTruthy(); | ||
// plug is rendered in another tree | ||
var plug_tree = React.render(<Plug outletId={ id } />, container2); | ||
ReactDOM.render(<Plug outletId={ id } />, container2); | ||
@@ -213,3 +225,3 @@ expect(outlet_registry.outlets.hasOwnProperty(id)).toBeTruthy(); | ||
// unmount the outlet | ||
expect(React.unmountComponentAtNode(container)).toBeTruthy(); | ||
expect(ReactDOM.unmountComponentAtNode(container)).toBeTruthy(); | ||
@@ -221,3 +233,3 @@ // outlet should still exist in the registry | ||
expect(React.unmountComponentAtNode(container2)).toBeTruthy(); | ||
expect(ReactDOM.unmountComponentAtNode(container2)).toBeTruthy(); | ||
@@ -233,3 +245,3 @@ expect(outlet_registry.outlets.hasOwnProperty(id)).toBeFalsy(); | ||
var outlet_tree = React.render(<Outlet outletId={ id } />, container); | ||
var outlet_tree = ReactDOM.render(<Outlet outletId={ id } />, container); | ||
@@ -240,3 +252,3 @@ expect(outlet_registry.outlets.hasOwnProperty(id)).toBeTruthy(); | ||
// plug is rendered in another tree | ||
var plug_tree = React.render(<Plug outletId={ id }>testing</Plug>, container2); | ||
ReactDOM.render(<Plug outletId={ id }>testing</Plug>, container2); | ||
@@ -246,24 +258,22 @@ expect(outlet_registry.outlets.hasOwnProperty(id)).toBeTruthy(); | ||
expect(TestUtils | ||
.findRenderedComponentWithType(outlet_tree, Outlet) | ||
.getDOMNode() | ||
.textContent).toBe("testing"); | ||
expect(ReactDOM.findDOMNode( | ||
TestUtils.findRenderedComponentWithType(outlet_tree, Outlet) | ||
).textContent).toBe("testing"); | ||
// unmount the outlet | ||
expect(React.unmountComponentAtNode(container)).toBeTruthy(); | ||
expect(ReactDOM.unmountComponentAtNode(container)).toBeTruthy(); | ||
// mount the outlet in another tree | ||
var outlet_tree_2 = React.render(<Outlet outletId={ id } />, container3); | ||
var outlet_tree_2 = ReactDOM.render(<Outlet outletId={ id } />, container3); | ||
expect(TestUtils | ||
.findRenderedComponentWithType(outlet_tree_2, Outlet) | ||
.getDOMNode() | ||
.textContent).toBe("testing"); | ||
expect(ReactDOM.findDOMNode( | ||
TestUtils.findRenderedComponentWithType(outlet_tree_2, Outlet) | ||
).textContent).toBe("testing"); | ||
// unmount the plug | ||
expect(React.unmountComponentAtNode(container2)).toBeTruthy(); | ||
expect(ReactDOM.unmountComponentAtNode(container2)).toBeTruthy(); | ||
expect(TestUtils | ||
.findRenderedComponentWithType(outlet_tree_2, Outlet) | ||
.getDOMNode()).toBeNull(); | ||
expect(ReactDOM.findDOMNode( | ||
TestUtils.findRenderedComponentWithType(outlet_tree_2, Outlet) | ||
)).toBeNull(); | ||
@@ -275,3 +285,3 @@ // outlet should still exist in the registry | ||
expect(React.unmountComponentAtNode(container3)).toBeTruthy(); | ||
expect(ReactDOM.unmountComponentAtNode(container3)).toBeTruthy(); | ||
@@ -291,3 +301,3 @@ expect(outlet_registry.outlets.hasOwnProperty(id)).toBeFalsy(); | ||
var plug = TestUtils.findRenderedComponentWithType(tree, Plug); | ||
expect(plug.getDOMNode()).toBeNull(); | ||
expect(ReactDOM.findDOMNode(plug)).toBeNull(); | ||
}); | ||
@@ -303,3 +313,3 @@ | ||
var plug = TestUtils.findRenderedComponentWithType(tree, Plug); | ||
expect(plug.getDOMNode()).toBeNull(); | ||
expect(ReactDOM.findDOMNode(plug)).toBeNull(); | ||
@@ -310,6 +320,5 @@ var tree2 = TestUtils.renderIntoDocument( | ||
expect(TestUtils | ||
.findRenderedDOMComponentWithClass(tree2, "tardy-outlet") | ||
.getDOMNode() | ||
.textContent).toBe("foobar"); | ||
expect(ReactDOM.findDOMNode( | ||
TestUtils.findRenderedDOMComponentWithClass(tree2, "tardy-outlet") | ||
).textContent).toBe("foobar"); | ||
}); | ||
@@ -321,3 +330,3 @@ | ||
var tree = React.render(<Plug outletId={ id } />, container); | ||
ReactDOM.render(<Plug outletId={ id } />, container); | ||
@@ -328,3 +337,3 @@ // ensure that the plug registered itself | ||
// cause the tree to be unmounted | ||
expect(React.unmountComponentAtNode(container)).toBeTruthy(); | ||
expect(ReactDOM.unmountComponentAtNode(container)).toBeTruthy(); | ||
@@ -331,0 +340,0 @@ // ensure that the plug unregistered itself |
@@ -34,3 +34,3 @@ var React = require("react"); | ||
if (children) { | ||
this.setState({ children: React.createElement('div', this.props, children) }); | ||
this.setState({ children: React.createElement("div", this.props, children) }); | ||
} else { | ||
@@ -37,0 +37,0 @@ this.setState({ children: null }); |
@@ -6,3 +6,4 @@ var React = require("react"); | ||
propTypes: { | ||
outletId: React.PropTypes.string.isRequired | ||
outletId: React.PropTypes.string.isRequired, | ||
children: React.PropTypes.node | ||
}, | ||
@@ -9,0 +10,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23444
13
391
2
12