forked from GordyD/3ree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add eslint, update babel config, fix issue with Object.assign and add…
… first test samples with karma
- Loading branch information
Showing
15 changed files
with
193 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
// I want to use babel-eslint for parsing! | ||
"parser": "babel-eslint", | ||
"ecmaFeatures": { | ||
"jsx": true, | ||
"classes": true, | ||
"modules": true, | ||
}, | ||
"env": { | ||
// I write for browser | ||
"browser": true, | ||
// in CommonJS | ||
"node": true | ||
}, | ||
"globals": { | ||
"process": false, | ||
"require": false, | ||
"define": false, | ||
"console": false, | ||
}, | ||
// To give you an idea how to override rule options: | ||
"rules": { | ||
"quotes": [2, "single"], | ||
"strict": [2, "never"], | ||
"eol-last": [0], | ||
"no-mixed-requires": [0], | ||
"no-underscore-dangle": [0], | ||
"no-bitwise": 2, | ||
"camelcase": 2, | ||
"eqeqeq": 2, | ||
"wrap-iife": [2, "inside"], | ||
"no-use-before-define": [2, "nofunc"], | ||
"no-caller": 2, | ||
"no-undef": 2, | ||
"new-cap": 2, | ||
"react/jsx-uses-react": 2, | ||
"react/jsx-uses-vars": 2, | ||
"react/react-in-jsx-scope": 2 | ||
}, | ||
"plugins": [ | ||
"react" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var webpackConfig = require('./webpack.config.js'); | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
browsers: [ 'PhantomJS' ], | ||
captureTimeout: 60000, | ||
browserNoActivityTimeout: 60000, // We need to accept that Webpack may take a while to build! | ||
singleRun: true, | ||
colors: true, | ||
frameworks: [ 'mocha', 'sinon', 'chai' ], // Mocha is our testing framework of choice | ||
files: [ | ||
'tests.webpack.js' | ||
], | ||
preprocessors: { | ||
'tests.webpack.js': [ 'webpack' ] // Preprocess with webpack and our sourcemap loader | ||
}, | ||
reporters: [ 'mocha' ], | ||
webpack: { // Simplified Webpack configuration | ||
module: { | ||
loaders: webpackConfig.module.loaders, | ||
noParse: [ | ||
/node_modules\/sinon/, | ||
] | ||
}, | ||
node: { | ||
fs: 'empty' | ||
} | ||
}, | ||
webpackServer: { | ||
noInfo: true // We don't want webpack output | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
require('babel-core/register'); | ||
require('babel-polyfill'); | ||
require('./server.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* global describe */ | ||
/* global it */ | ||
/* global afterEach */ | ||
|
||
import sinon from 'sinon'; | ||
import chai from 'chai'; | ||
|
||
var expect = chai.expect; | ||
|
||
import configureStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
import nock from 'nock'; | ||
|
||
import * as actions from '../universal/actions/PulseActions.js'; | ||
import * as types from '../universal/constants/ActionTypes'; | ||
|
||
describe('PulseActions', () => { | ||
afterEach(function() { | ||
actions.__ResetDependency__('request') | ||
}) | ||
|
||
/** | ||
* Example of writing a test on a syncronous action creator | ||
*/ | ||
describe('setUserId', () => { | ||
it('should return action with type SET_USER_ID and userId equal to 200', () => { | ||
let action = actions.setUserId(200); | ||
expect(action.type).to.equal(types.SET_USER_ID); | ||
expect(action.userId).to.equal(200); | ||
}); | ||
|
||
it('should return action with type SET_USER_ID and userId equal to 6700102', () => { | ||
let action = actions.setUserId(6700102); | ||
expect(action.type).to.equal(types.SET_USER_ID); | ||
expect(action.userId).to.equal(6700102); | ||
}); | ||
}); | ||
|
||
/** | ||
* Example of writing a test on an asyncronous action creator | ||
*/ | ||
// describe('loadEvents', () => { | ||
// const mockStore = configureStore([thunk]); | ||
// it('should run', (done) => { | ||
// let requestMock = { | ||
// get: () => { | ||
// set: () => { | ||
// end: (x) => { | ||
// x(null, { | ||
// body: [ { name: 'Awesome', value: 54 } ] | ||
// }); | ||
// } | ||
// } | ||
// } | ||
// }; | ||
|
||
// actions.__Rewire__('request', requestMock); | ||
|
||
// let expectedActions = [ | ||
// { type: 'LOAD_EVENTS_REQUEST' }, | ||
// { type: 'LOAD_EVENTS_SUCCESS', events: [ { name: 'Awesome', value: 54 } ] } | ||
// ]; | ||
|
||
// let initialState = {pulseApp: { events: [], userId: 'baseUser'} }; | ||
// let store = mockStore(initialState, expectedActions, done); | ||
|
||
// store.dispatch(actions.loadEvents()); | ||
// }); | ||
// }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
var context = require.context('./test', true, /.js$/); // Load files in /test with filename matching * .test.js | ||
context.keys().forEach(context); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters