-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: auto require setup file If `test/.setup.js` exists, should auto require it * deps: upgrade debug to 2.5.2 * test: use cross-env fix env on windows
- Loading branch information
Showing
15 changed files
with
246 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules/ | ||
coverage/ | ||
test/fixtures/enzyme-example-mocha/ |
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
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
"childprocess": "^2.0.2", | ||
"commander": "^2.9.0", | ||
"common-bin": "^1.0.0", | ||
"debug": "^2.4.4", | ||
"debug": "^2.5.2", | ||
"detect-port": "^1.0.7", | ||
"egg-utils": "^1.0.0", | ||
"glob": "^7.1.1", | ||
|
@@ -26,11 +26,20 @@ | |
}, | ||
"devDependencies": { | ||
"autod": "^2.7.1", | ||
"babel": "^6.3.26", | ||
"babel-preset-airbnb": "^1.0.1", | ||
"babel-register": "^6.4.3", | ||
"coffee": "^3.3.0", | ||
"cross-env": "^3.1.3", | ||
"egg-ci": "^1.1.0", | ||
"enzyme": "^2.0.0", | ||
"eslint": "^3.12.2", | ||
"eslint-config-egg": "^3.2.0", | ||
"mm": "^2.0.0" | ||
"jsdom": "^8.0.1", | ||
"mm": "^2.0.0", | ||
"react": "^0.14.7", | ||
"react-addons-test-utils": "^0.14.7", | ||
"react-dom": "^0.14.7" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
@@ -40,8 +49,8 @@ | |
"author": "fengmk2 <[email protected]> (https://fengmk2.com)", | ||
"scripts": { | ||
"lint": "eslint bin lib test *.js", | ||
"test": "TEST_TIMEOUT=3600000 TESTS=test/*.test.js bin/egg-bin.js test", | ||
"cov": "TEST_TIMEOUT=3600000 TESTS=test/*.test.js bin/egg-bin.js cov", | ||
"test": "cross-env TEST_TIMEOUT=3600000 TESTS=test/*.test.js bin/egg-bin.js test", | ||
"cov": "cross-env TEST_TIMEOUT=3600000 TESTS=test/*.test.js bin/egg-bin.js cov", | ||
"ci": "npm run lint && npm run cov", | ||
"autod": "autod" | ||
}, | ||
|
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,3 @@ | ||
{ | ||
presets: ["airbnb"] | ||
} |
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 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
node_modules | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Leland Richardson | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 @@ | ||
# enzyme-example-mocha | ||
Example project with React + Enzyme + Mocha |
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,31 @@ | ||
{ | ||
"name": "enzyme-example-mocha", | ||
"version": "0.1.0", | ||
"description": "Example project with React + Enzyme + Mocha", | ||
"main": "build/index.js", | ||
"scripts": { | ||
"test": "mocha test/.setup.js test/**/*-test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/lelandrichardson/enzyme-example-mocha.git" | ||
}, | ||
"author": "Leland Richardson <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/lelandrichardson/enzyme-example-mocha/issues" | ||
}, | ||
"homepage": "https://github.com/lelandrichardson/enzyme-example-mocha", | ||
"devDependencies": { | ||
"babel": "^6.3.26", | ||
"babel-preset-airbnb": "^1.0.1", | ||
"babel-register": "^6.4.3", | ||
"enzyme": "^2.0.0", | ||
"jsdom": "^8.0.1", | ||
"react-addons-test-utils": "^0.14.7" | ||
}, | ||
"dependencies": { | ||
"react": "^0.14.7", | ||
"react-dom": "^0.14.7" | ||
} | ||
} |
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,22 @@ | ||
import React, { PropTypes } from 'react'; | ||
|
||
const propTypes = {}; | ||
|
||
const defaultProps = {}; | ||
|
||
class Foo extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="foo" /> | ||
); | ||
} | ||
} | ||
|
||
Foo.propTypes = propTypes; | ||
Foo.defaultProps = defaultProps; | ||
|
||
export default Foo; |
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,20 @@ | ||
require('babel-register')(); | ||
|
||
var jsdom = require('jsdom').jsdom; | ||
|
||
var exposedProperties = ['window', 'navigator', 'document']; | ||
|
||
global.document = jsdom(''); | ||
global.window = document.defaultView; | ||
Object.keys(document.defaultView).forEach((property) => { | ||
if (typeof global[property] === 'undefined') { | ||
exposedProperties.push(property); | ||
global[property] = document.defaultView[property]; | ||
} | ||
}); | ||
|
||
global.navigator = { | ||
userAgent: 'node.js' | ||
}; | ||
|
||
documentRef = document; |
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,18 @@ | ||
import React from 'react'; | ||
import assert from 'assert'; | ||
import { shallow, mount, render } from 'enzyme'; | ||
import Foo from '../src/Foo'; | ||
|
||
describe("A suite", () => { | ||
it("contains foo", () => { | ||
assert(shallow(<Foo />).contains(<div className="foo" />)); | ||
}); | ||
|
||
it("contains .foo", () => { | ||
assert(shallow(<Foo />).is('.foo')); | ||
}); | ||
|
||
it("contains .foo length 1", () => { | ||
assert(mount(<Foo />).find('.foo').length === 1); | ||
}); | ||
}); |