Skip to content

Commit

Permalink
Merge pull request react-bootstrap#99 from react-bootstrap/react-15.2
Browse files Browse the repository at this point in the history
Update for React v15.2.x
  • Loading branch information
jquense committed Jul 11, 2016
2 parents 109f37f + bb3a624 commit 4e5d7f5
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 51 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -27,3 +27,7 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# Build artifacts
/examples/static
/lib
12 changes: 6 additions & 6 deletions examples/PropTable.js
Expand Up @@ -121,9 +121,9 @@ const PropTable = React.createClass({
},

getType(prop) {
let type = prop.type || {};
let name = this.getDisplayTypeName(type.name);
let doclets = prop.doclets || {};
const type = prop.type || {};
const name = this.getDisplayTypeName(type.name);
const doclets = prop.doclets || {};

switch (name) {
case 'object':
Expand All @@ -139,9 +139,9 @@ const PropTable = React.createClass({
return i === (list.length - 1) ? current : current.concat(' | ');
}, []);
case 'array':
let child = this.getType({ type: type.value });

return <span>{'array<'}{ child }{'>'}</span>;
return (
<span>{'array<'}{this.getType({ type: type.value })}{'>'}</span>
);
case 'enum':
return this.renderEnum(type);
case 'custom':
Expand Down
16 changes: 10 additions & 6 deletions examples/server.js
@@ -1,9 +1,9 @@
let webpack = require('webpack');
let WebpackDevServer = require('webpack-dev-server');
let config = require('../webpack/examples.config');
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';

new WebpackDevServer(webpack(config), {
import config from '../webpack/examples.config';

const server = new WebpackDevServer(webpack(config), {
contentBase: 'examples',
publicPath: '/static/',
hot: true,
Expand All @@ -12,10 +12,14 @@ new WebpackDevServer(webpack(config), {
stats: {
colors: true
}
}).listen(3000, 'localhost', function (err) {
});

server.listen(3000, 'localhost', err => {
/* eslint-disable no-console */
if (err) {
console.log(err);
console.error(err);
}

console.log('Listening at localhost:3000');
/* eslint-enable no-console */
});
15 changes: 7 additions & 8 deletions package.json
Expand Up @@ -24,13 +24,12 @@
"clean": "rimraf lib",
"clean:examples": "rimraf examples/static",
"build": "npm run clean && babel src --out-dir lib",
"build:examples": "npm run clean:examples && babel-node ./webpack/run-webpack --config docs.config.js",
"examples": "npm run clean:examples && babel-node ./examples/server.js",
"lint": "eslint src test",
"build:examples": "npm run clean:examples && webpack --config webpack/docs.config.js",
"examples": "npm run clean:examples && babel-node examples/server.js",
"lint": "eslint examples/*.js src test *.js",
"test": "npm run lint && npm run testonly",
"testonly": "karma start --single-run",
"tdd": "karma start",
"coverage": "COVERAGE=true npm run testonly",
"release": "release"
},
"peerDependencies": {
Expand All @@ -41,7 +40,7 @@
"@monastic.panic/component-playground": "^2.0.0",
"babel": "^5.8.38",
"babel-core": "^5.8.38",
"babel-eslint": "^6.1.0",
"babel-eslint": "^6.1.2",
"babel-loader": "^5.4.0",
"babel-plugin-object-assign": "^1.2.1",
"chai": "^3.5.0",
Expand Down Expand Up @@ -71,11 +70,11 @@
"mocha": "^2.5.3",
"node-libs-browser": "^1.0.0",
"raw-loader": "^0.5.1",
"react": "~15.1.0",
"react-addons-test-utils": "~15.1.0",
"react": "^15.2.1",
"react-addons-test-utils": "^15.2.1",
"react-bootstrap": "^0.29.5",
"react-component-metadata": "^2.1.1",
"react-dom": "~15.1.0",
"react-dom": "^15.2.1",
"react-hot-loader": "^1.3.0",
"release-script": "^1.0.2",
"rimraf": "^2.5.3",
Expand Down
1 change: 1 addition & 0 deletions src/Position.js
Expand Up @@ -60,6 +60,7 @@ class Position extends React.Component {
delete props.target;
delete props.container;
delete props.containerPadding;
delete props.shouldUpdatePosition;

const child = React.Children.only(children);
return cloneElement(
Expand Down
20 changes: 10 additions & 10 deletions test/ModalSpec.js
@@ -1,13 +1,16 @@
import jQuery from 'jquery';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-addons-test-utils';
import Modal from '../src/Modal';
import { render } from './helpers';
import jquery from 'jquery';
import ReactDOM from 'react-dom';
import simulant from 'simulant';

import Modal from '../src/Modal';

import Transition from '../src/Transition';

let $ = componentOrNode => jquery(ReactDOM.findDOMNode(componentOrNode));
import { render, shouldWarn } from './helpers';

const $ = componentOrNode => jQuery(ReactDOM.findDOMNode(componentOrNode));

describe('Modal', function () {
let mountPoint;
Expand Down Expand Up @@ -362,18 +365,15 @@ describe('Modal', function () {
});

it('Should warn if the modal content is not focusable', function () {
let Dialog = ()=> ({ render(){ return <div/>; } });
shouldWarn('The modal content node does not accept focus');

sinon.stub(console, 'error');
const Dialog = () => <div />;

render(
<Modal show>
<Dialog />
</Modal>
, focusableContainer);

expect(console.error).to.have.been.calledOnce;
console.error.restore();
});
});

Expand Down
13 changes: 8 additions & 5 deletions test/PositionSpec.js
Expand Up @@ -9,10 +9,13 @@ import overlayPositionUtils from '../src/utils/overlayPositionUtils';
import {render} from './helpers';

describe('Position', function () {
// Swallow extra props.
const Span = () => <span />;

it('Should output a child', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Position>
<span>Text</span>
<Span>Text</Span>
</Position>
);
assert.equal(ReactDOM.findDOMNode(instance).nodeName, 'SPAN');
Expand All @@ -22,8 +25,8 @@ describe('Position', function () {
expect(() => {
ReactTestUtils.renderIntoDocument(
<Position>
<span>Text</span>
<span>Another Text</span>
<Span>Text</Span>
<Span>Another Text</Span>
</Position>
);
}).to.throw(Error, /onlyChild must be passed a children with exactly one child/);
Expand Down Expand Up @@ -61,7 +64,7 @@ describe('Position', function () {
target={() => this.refs[this.state.target]}
fakeProp={this.state.fakeProp}
>
<div />
<Span />
</Position>
</div>
);
Expand Down Expand Up @@ -114,7 +117,7 @@ describe('Position', function () {
shouldUpdatePosition
fakeProp={this.state.fakeProp}
>
<div />
<Span />
</Position>
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion test/TransitionSpec.js
Expand Up @@ -246,13 +246,16 @@ describe('Transition', function () {
}

render() {
const { ...props } = this.props;
delete props.initialIn;

return (
<Transition
ref="transition"
unmountOnExit
in={this.state.in}
timeout={10}
{...this.props}
{...props}
>
<div />
</Transition>
Expand Down
6 changes: 2 additions & 4 deletions test/helpers.js
@@ -1,10 +1,8 @@
import ReactDOM from 'react-dom';
import { cloneElement } from 'react';
import ReactDOM from 'react-dom';

export function shouldWarn(about) {
console.warn.called.should.be.true;
console.warn.calledWithMatch(about).should.be.true;
console.warn.reset();
console.error.expected.push(about);
}

/**
Expand Down
36 changes: 28 additions & 8 deletions test/index.js
@@ -1,4 +1,5 @@
import 'es5-shim';

import chai from 'chai';
import sinonChai from 'sinon-chai';

Expand All @@ -8,17 +9,36 @@ chai.use(sinonChai);
global.expect = chai.expect;
global.assert = chai.assert;

beforeEach(function() {
sinon.stub(console, 'warn');
});
beforeEach(() => {
sinon.stub(console, 'error', msg => {
let expected = false;

afterEach(function() {
if (typeof console.warn.restore === 'function') {
assert(!console.warn.called, () => {
return `${console.warn.getCall(0).args[0]} \nIn '${this.currentTest.fullTitle()}'`;
console.error.expected.forEach(about => {
if (msg.indexOf(about) !== -1) {
console.error.warned[about] = true;
expected = true;
}
});
console.warn.restore();

if (expected) {
return;
}

console.error.threw = true;
throw new Error(msg);
});

console.error.expected = [];
console.error.warned = Object.create(null);
console.error.threw = false;
});

afterEach(() => {
if (!console.error.threw && console.error.expected.length) {
expect(console.error.warned).to.have.keys(console.error.expected);
}

console.error.restore();
});

describe('Process environment for tests', function () {
Expand Down

0 comments on commit 4e5d7f5

Please sign in to comment.