-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 219c8f7
Showing
9 changed files
with
196 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.settings.xml | ||
node_modules/ | ||
bower_components/ | ||
.DS_Store | ||
*.swp |
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 @@ | ||
language: node_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2014 Andrew Hanna | ||
|
||
MIT License | ||
|
||
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,22 @@ | ||
# chai-react | ||
|
||
chai-react is an extension to the [chai](http://chaijs.com/) assertion library that | ||
provides a set of React-specific assertions. | ||
|
||
## Contributing | ||
|
||
To run the test suite, run `npm install` (requires | ||
[Node.js](http://nodejs.org/) to be installed on your system), and open | ||
`test/index.html` in your web browser. | ||
|
||
## License | ||
|
||
Copyright (c) 2014 Andrew Hanna | ||
|
||
MIT License (see the LICENSE file) | ||
|
||
## Credits | ||
|
||
Thanks to [John Firebaugh](https://github.com/jfirebaugh) for providing | ||
[chai-jquery](https://github.com/chaijs/chai-jquery/), which served as a | ||
foundation for this plugin. |
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": "chai-react", | ||
"main": "chai-react.js", | ||
"version": "0.0.1", | ||
"authors": [ | ||
"Andrew Hanna <[email protected]>" | ||
], | ||
"description": "React assertions for Chai.", | ||
"moduleType": [ | ||
"amd", | ||
"node" | ||
], | ||
"keywords": [ | ||
"chai", | ||
"react", | ||
"testing", | ||
"assertion" | ||
], | ||
"license": "MIT", | ||
"private": true, | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"react": "~0.10.0" | ||
} | ||
} |
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,56 @@ | ||
(function (chaiReact) { | ||
// Module systems magic dance. | ||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") { | ||
// NodeJS | ||
module.exports = chaiReact; | ||
} else if (typeof define === "function" && define.amd) { | ||
// AMD | ||
define(['react'], function (React) { | ||
return function (chai, utils) { | ||
return chaiReact(chai, utils, React); | ||
}; | ||
}); | ||
} else { | ||
// Other environment (usually <script> tag): plug in to global chai instance directly. | ||
chai.use(function (chai, utils) { | ||
return chaiReact(chai, utils, React); | ||
}); | ||
} | ||
}(function (chai, utils, React) { | ||
var inspect = utils.inspect, | ||
flag = utils.flag; | ||
|
||
window.chaiReact = React; | ||
|
||
var div = document.createElement('div'), | ||
sampleClass = React.createClass({ | ||
render: function () { | ||
return React.DOM.div(); | ||
} | ||
}), | ||
sampleComponent = React.renderComponent(sampleClass(), div); | ||
|
||
chai.Assertion.addMethod('state', function (name, value) { | ||
var component = flag(this, 'object'), | ||
state = component.state, | ||
actual = state[name]; | ||
|
||
if (!flag(this, 'negate') || undefined === value) { | ||
this.assert( | ||
undefined !== actual, | ||
'expected #{this} to have state.' + name + ' #{exp}', | ||
'expected #{this} not to have state.' + name + ' #{exp}' | ||
); | ||
} | ||
|
||
if (undefined !== value) { | ||
this.assert( | ||
value === actual, | ||
'expected #{this} to have state.' + name + ' with the value #{exp}, but the value was #{act}', | ||
'expected #{this} not to have state.' + name + ' with the value #{act}' | ||
); | ||
} | ||
|
||
flag(this, 'object', actual); | ||
}); | ||
})); |
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,32 @@ | ||
{ | ||
"author": "Andrew Hanna <[email protected]>", | ||
"name": "chai-react", | ||
"description": "React assertions for the Chai assertion library", | ||
"keywords": [ | ||
"test", | ||
"assertion", | ||
"assert", | ||
"testing", | ||
"react" | ||
], | ||
"version": "0.0.1", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/percyhanna/chai-react" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/percyhanna/chai-react/issues" | ||
}, | ||
"scripts": { | ||
"test": "mocha-phantomjs test/index.html" | ||
}, | ||
"main": "./chai-react", | ||
"engines": { | ||
"node": ">= 0.4.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "1", | ||
"mocha": "1", | ||
"mocha-phantomjs": "3" | ||
} | ||
} |
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,4 @@ | ||
describe("React assertions", function() { | ||
chai.use(function (chai, utils) { | ||
}); | ||
}); |
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,23 @@ | ||
<html> | ||
<head> | ||
<title>Mocha</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" /> | ||
<script src="../bower_components/react/react.js"></script> | ||
<script src="../node_modules/mocha/mocha.js"></script> | ||
<script src="../node_modules/chai/chai.js"></script> | ||
<script src="../chai-jquery.js"></script> | ||
<script> | ||
mocha.setup('bdd'); | ||
var should = chai.should(); | ||
window.onload = function () { | ||
(window.mochaPhantomJS || window.mocha).run(); | ||
}; | ||
</script> | ||
<script src="jquery-inspect-spec.js"></script> | ||
<script src="chai-jquery-spec.js"></script> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
</body> | ||
</html> |