Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a convenience property to jasmineReact to point to React.addons.TestUtils #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ jasmineReact.getJasmineContent = function(){
};
```

## jasmineReact.TestUtils

This is not a function. It's simply an extra property on jasmineReact that will reference React.addons.TestUtils if you're using react-with-addons.js instead of react.js. See http://facebook.github.io/react/docs/test-utils.html for api reference.


# Installation

To install, include the `src/jasmine-react.js` file in your jasmine spec helpers list.
Expand Down
7 changes: 6 additions & 1 deletion src/jasmine-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jasmineReact.setDisplayNameForClass = function(klass, displayName){

this.jasmineReactClassDisplayNameOverrides_ = this.jasmineReactClassDisplayNameOverrides_ || [];
this.jasmineReactClassDisplayNameOverrides_.push({klass: klass, originalDisplayName: originalDisplayName});

return klass;
};

Expand Down Expand Up @@ -131,6 +131,11 @@ jasmineReact.getJasmineContent = function(){
return document.getElementById("jasmine_content");
};

if (React.addons && React.addons.TestUtils)
{
jasmineReact.TestUtils = React.addons.TestUtils;
}

afterEach(function(){
jasmineReact.removeAllSpies();
jasmineReact.resetComponentStubs();
Expand Down
26 changes: 26 additions & 0 deletions test/index-testutils.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>jasmine-react tests</title>

<!-- jasmine dependencies: -->
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css">
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-runner.js"></script>

<!-- source dependencies: -->
<script type="text/javascript" src="lib/react-with-addons.js"></script>

<!-- source files: -->
<script type="text/javascript" src="../src/jasmine-react.js"></script>

<!-- spec files: -->
<script type="text/javascript" src="spec/jasmine-react-testutils-spec.js"></script>

</head>

<body>
<div id="jasmine_content"></div>
</body>
</html>
Loading