Skip to content

Commit c628137

Browse files
committed
Added tests for noscript.
1 parent ca261d1 commit c628137

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed

tests/extendReactClass.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ describe('extendReactClass', () => {
1515

1616
global.window = document.defaultView;
1717
});
18-
1918
context('using default styles', () => {
20-
it('exposes styles through styles property', (done) => {
19+
it('exposes styles through this.props.styles property', (done) => {
2120
let Component,
2221
styles;
2322

@@ -56,9 +55,8 @@ describe('extendReactClass', () => {
5655
TestUtils.renderIntoDocument(<Component bar='baz' />);
5756
});
5857
});
59-
60-
context('using explicit styles', () => {
61-
it('exposes styles through styles property', (done) => {
58+
context('overwriting default styles using "styles" property of the extended component', () => {
59+
it('overwrites default styles', (done) => {
6260
let Component,
6361
styles;
6462

@@ -73,9 +71,35 @@ describe('extendReactClass', () => {
7371
foo: 'foo-1'
7472
};
7573

76-
Component = extendReactClass(Component);
74+
Component = extendReactClass(Component, {
75+
foo: 'foo-0',
76+
bar: 'bar-0'
77+
});
7778

7879
TestUtils.renderIntoDocument(<Component styles={styles} />);
7980
});
8081
});
82+
context('rendering Component that returns null', () => {
83+
it('generates <noscript> element', () => {
84+
let Component,
85+
component,
86+
shallowRenderer;
87+
88+
shallowRenderer = TestUtils.createRenderer();
89+
90+
Component = class extends React.Component {
91+
render () {
92+
null
93+
}
94+
};
95+
96+
Component = extendReactClass(Component);
97+
98+
shallowRenderer.render(<Component />);
99+
100+
component = shallowRenderer.getRenderOutput();
101+
102+
expect(component.type).to.equal('noscript');
103+
});
104+
});
81105
});

tests/wrapStatelessFunction.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
import {
44
expect
55
} from 'chai';
6-
6+
import React from 'react';
7+
import TestUtils from 'react-addons-test-utils';
78
import wrapStatelessFunction from './../src/wrapStatelessFunction';
89

910
describe('wrapStatelessFunction', () => {
1011
it('hoists static own properties from the input component to the wrapped component', () => {
11-
let Component, WrappedComponent, styles;
12+
let Component,
13+
WrappedComponent,
14+
styles;
1215

1316
styles = {
1417
foo: 'foo-1'
@@ -71,4 +74,23 @@ describe('wrapStatelessFunction', () => {
7174
});
7275
});
7376
});
77+
context('rendering Component that returns null', () => {
78+
it('generates <noscript> element', () => {
79+
let Component,
80+
component,
81+
shallowRenderer;
82+
83+
shallowRenderer = TestUtils.createRenderer();
84+
85+
Component = wrapStatelessFunction(() => {
86+
return null;
87+
});
88+
89+
shallowRenderer.render(<Component />);
90+
91+
component = shallowRenderer.getRenderOutput();
92+
93+
expect(component.type).to.equal('noscript');
94+
});
95+
});
7496
});

0 commit comments

Comments
 (0)