Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Add rudimentary test runner #5

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
build
node_modules
Empty file added build/.gitkeep
Empty file.
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@
"art": "~0.9.0",
"react": "0.8.0"
},
"devDependencies": {},
"devDependencies": {
"jsx-loader": "git://github.com/petehunt/jsx-loader.git",
"webpack": "~1.0.0"
},
"scripts": {
"build:test": "webpack --devtool source-map src/__tests__/ReactART-test.js build/react-art-test.js"
},
"engines": {
"node": ">=0.10.0"
}
}
}
11 changes: 4 additions & 7 deletions src/__tests__/ReactART-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

"use strict";

require('mock-modules')
.dontMock('ReactART');

var React;
var ReactTestUtils;

Expand All @@ -36,7 +33,7 @@ var Missing = {};

function testDOMNodeStructure(domNode, expectedStructure) {
expect(domNode).toBeDefined();
expect(domNode.nodeName).toBe(expectedStructure.nodeName);
expect(domNode.nodeName.toUpperCase()).toBe(expectedStructure.nodeName);
for (var prop in expectedStructure) {
if (!expectedStructure.hasOwnProperty(prop)) continue;
if (prop != 'nodeName' && prop != 'children') {
Expand All @@ -57,10 +54,10 @@ function testDOMNodeStructure(domNode, expectedStructure) {
describe('ReactART', function() {

beforeEach(function() {
React = require('React');
ReactTestUtils = require('ReactTestUtils');
React = require('react');
ReactTestUtils = require('react/lib/ReactTestUtils');

var ReactART = require('ReactART');
var ReactART = require('../ReactART.js');
var ARTSVGMode = require('art/modes/svg');
var ARTCurrentMode = require('art/modes/current');

Expand Down
17 changes: 17 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Testing

To set up tests on your computer:

1. In a clone of React, run:

```
grunt build:test
grunt build:npm-react
cd build/npm/react/ && npm link
```
1. In `react-art/`, run `npm link react`.

Afterwards, to run tests:

1. Run `npm run build:test`.
1. Open `test/index.html` in a browser.
48 changes: 48 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<title>ReactART tests</title>
<link rel="stylesheet" type="text/css" href="../vendor/jasmine/jasmine.css">
</head>
<body>
<script type="text/javascript" src="../vendor/jasmine/jasmine.js"></script>
<script type="text/javascript" src="../vendor/jasmine/jasmine-html.js"></script>

<script type="text/javascript" src="../build/react-art-test.js"></script>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;

var htmlReporter = new jasmine.HtmlReporter();

jasmineEnv.addReporter(htmlReporter);

jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};

// Clean up any nodes the previous test might have added.
jasmineEnv.afterEach(function() {
removeNextSiblings(document.body);
});

execJasmine();

function removeNextSiblings(node) {
var parent = node && node.parentNode;
if (parent) {
while (node.nextSibling) {
parent.removeChild(node.nextSibling);
}
}
}

function execJasmine() {
jasmineEnv.execute();
}

})();
</script>
</body>
</html>
20 changes: 20 additions & 0 deletions vendor/jasmine/MIT.LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2008-2011 Pivotal Labs

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.
Loading