Skip to content

Commit 133647a

Browse files
committed
reorganize tests
1 parent 31c5479 commit 133647a

11 files changed

Lines changed: 75 additions & 69 deletions

File tree

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"eol-last": 2,
1818
"dot-notation": [2, { "allowKeywords": true }],
1919
"semi": [0, "never"],
20+
"semi-spacing": 0,
2021
"curly": 0,
2122
"eqeqeq": [2, "allow-null"],
2223
"no-undef": 2,

_test-bootstrap.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

karma.conf-ci.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = function(config) {
7878
'_test-bootstrap.js': ['webpack']
7979
},
8080

81-
webpack: require('./webpack.configs').test,
81+
webpack: require('./build/test.config'),
8282
webpackServer: {
8383
noInfo: true
8484
},

karma.conf.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
'use strict';
22

33
module.exports = function (config) {
4-
5-
6-
//console.log(process.env.TRAVIS_CI)
74

85
config.set({
96

@@ -15,7 +12,7 @@ module.exports = function (config) {
1512
'./vendor/phantomjs-shim.js',
1613
'./vendor/sinon-1.10.3.js',
1714
'./vendor/jquery-1.11.2.min.js',
18-
'_test-bootstrap.js',
15+
'./test/index.js'
1916
],
2017

2118
reporters: ['mocha'],
@@ -30,12 +27,12 @@ module.exports = function (config) {
3027
browsers: [ 'PhantomJS'],
3128

3229
preprocessors: {
33-
'_test-bootstrap.js': ['webpack', 'sourcemap']
30+
'test/index.js': ['webpack', 'sourcemap']
3431
},
3532

36-
webpack: require('./webpack.configs').test,
33+
webpack: require('./build/test.config'),
3734
webpackServer: {
3835
noInfo: true
3936
}
4037
});
41-
};
38+
};

package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"react-component"
2727
],
2828
"scripts": {
29-
"test": "npm run lint && mocha -R spec ./test/server.js && node _test-versions.js",
29+
"test": "npm run lint && npm run test:all",
3030
"test:all": "mocha -R spec ./test/server.js && karma start karma.conf.js --single-run=true",
3131
"tdd": "karma start",
3232
"lint": "eslint src --ext .jsx --ext .js",
@@ -43,14 +43,14 @@
4343
"build:lib": "npm run clean:lib && npm run compile:lib && npm run assets:lib",
4444
"build:docs": "npm run clean:docs && npm run compile:docs && npm run assets:docs",
4545
"build:dist": "npm run clean:dist && npm run compile:dist && npm run less && npm run assets:dist",
46-
"build": "build:lib && build:dist & build:docs",
46+
"build": "npm run build:lib && npm run build:dist & npm run build:docs",
4747
"docs": "npm run clean:docs && webpack-dev-server --config ./build/docs.config.js --hot",
4848
"dev": "webpack-dev-server --config ./build/dev.config.js --hot",
4949

5050
"major": "release major",
5151
"minor": "release minor",
5252
"patch": "release patch",
53-
"alpha": "release --preid beta",
53+
"alpha": "release --preid alpha",
5454
"beta": "release --preid beta"
5555
},
5656
"homepage": "http://jquense.github.io/react-widgets/docs/",
@@ -112,12 +112,7 @@
112112
"react-bootstrap": "0.24.5-react-pre.0",
113113
"react-dom": "^0.14.0-beta3",
114114
"react-router": "^1.0.0-beta3",
115-
<<<<<<< HEAD
116-
"react-widgets-globalize-localizer": "^1.0.0-alpha",
117-
=======
118-
"react-widgets-globalize-localizer": "file:../react-widgets-globalize-localizer",
119115
"release-script": "^0.2.7",
120-
>>>>>>> reset version and release scripts
121116
"rimraf": "^2.4.2",
122117
"scriptjs": "^2.5.7",
123118
"style-loader": "^0.12.3",

src/Multiselect.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ var Multiselect = React.createClass({
279279
<div>
280280
{ shouldRenderPopup && [
281281
<List ref="list"
282-
key='0'
282+
key={0}
283283
{...listProps}
284284
readOnly={!!readOnly}
285285
disabled={!!disabled}
@@ -299,7 +299,7 @@ var Multiselect = React.createClass({
299299
}}
300300
/>,
301301
shouldShowCreate &&
302-
<ul role='listbox' id={createID} className="rw-list rw-multiselect-create-tag" key='1'>
302+
<ul key={1} role='listbox' id={createID} className="rw-list rw-multiselect-create-tag">
303303
<li onClick={this._onCreate.bind(null, searchTerm)}
304304
role='option'
305305
id={createOptionID}

src/util/configuration.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import animate from './dom/animate';
33
function error(){
44
throw new Error(
55
'[React Widgets] You are attempting to use a widget that requires localization (DateTimePicker, NumberPicker)' +
6-
'but there is no localizer set. IN order to use these widgets please install a localizer')
6+
'but there is no localizer set. In order to use these widgets please install a localizer')
77
}
88

99
let dummy = {
10+
formats: error,
1011
parse: error,
1112
format:error,
1213
firstOfWeek: error

test/.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"$": true,
77
"sinon": true,
88
"expect": true,
9+
"sinon": true,
910
"__REACT_VERSION__": true
1011
}
1112
}
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
'use strict';
2-
var server = require('karma').server
2+
var Server = require('karma').Server
33
, webpack = require('webpack')
4-
, webpackConfig = require('./webpack.configs').test;
4+
, webpackConfig = require('../build/test.config');
55

66
var plugins = webpackConfig.plugins || [];
77

88
webpackConfig.externals = {
9-
'react': 'window.React',
10-
'react/addons': 'window.React'
9+
'react': 'window.React',
10+
'react-dom': 'window.React',
11+
'react/addons': 'window.React',
12+
'react-dom/server': 'window.React'
1113
}
1214

1315

14-
var SUPPORTED_VERSIONS = ["0.12.2", "0.13.0"];
16+
var SUPPORTED_VERSIONS = ['0.14.0-rc'];
1517

1618

1719
series(SUPPORTED_VERSIONS, function(version, idx, next){
1820
console.log('-------------------------------------------');
1921
console.log('------- Testing React version: ' + version );
2022
console.log('-------------------------------------------');
2123

22-
server.start(
23-
config(version)
24-
, function(exitCode) {
25-
if ( exitCode )
26-
process.exit(exitCode)
24+
var server = new Server(config(version), function(exitCode) {
25+
if ( exitCode )
26+
process.exit(exitCode)
2727

28-
next();
29-
});
30-
}, function(){
31-
process.exit(0)
28+
next();
29+
});
30+
31+
32+
server.start();
3233
})
3334

3435
function config(version){
3536

3637
webpackConfig.plugins = plugins.concat(
3738
new webpack.DefinePlugin({
38-
'__REACT_VERSION__': JSON.stringify(version),
39+
'__REACT_VERSION__': JSON.stringify(version)
3940
})
4041
)
4142

@@ -50,7 +51,7 @@ function config(version){
5051
'https://cdnjs.cloudflare.com/ajax/libs/react/' + version + '/react-with-addons.js',
5152
'./vendor/sinon-1.10.3.js',
5253
'./vendor/jquery-1.11.2.min.js',
53-
'_test-bootstrap.js'
54+
'./test/index.js'
5455
],
5556

5657
reporters: ['mocha'],
@@ -65,7 +66,7 @@ function config(version){
6566
browsers: ['PhantomJS'],
6667

6768
preprocessors: {
68-
'_test-bootstrap.js': ['webpack']
69+
'test/index.js': ['webpack']
6970
},
7071

7172
webpack: webpackConfig,

test/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
var React = require('react');
3+
var widgetHelpers = require('../src/util/widgetHelpers')
4+
var globalize = require('globalize')
5+
var configure = require('../src/configure')
6+
var localizers = require('../src/globalize-localizers')
7+
8+
configure.setLocalizers(localizers(globalize))
9+
10+
//disable this particular optimization
11+
sinon.stub(widgetHelpers, 'isFirstFocusedRender', ()=> true)
12+
13+
var testsContext = require.context('../test', true, /\.browser\.(js$|jsx$)/);
14+
15+
if ( typeof __REACT_VERSION__ !== 'undefined' ) {
16+
it('Ensure we are testing against the correct version of React: ' + __REACT_VERSION__, ()=> {
17+
expect(React.version).to.equal(__REACT_VERSION__)
18+
})
19+
}
20+
21+
testsContext.keys().forEach(testsContext);

0 commit comments

Comments
 (0)