forked from yui/grover
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Adding initial tests
- Loading branch information
Showing
5 changed files
with
121 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
Binary file not shown.
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 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Test One</title> | ||
</head> | ||
<body> | ||
<script src="http://davglass.homelinux.com/yui/yui3/build/yui/yui-min.js"></script> | ||
<script> | ||
YUI().use('test', function(Y) { | ||
var suite = new Y.Test.Suite('Suite Bad'); | ||
|
||
for (var i = 1; i <= 5; i++) { | ||
suite.add(new Y.Test.Case({ | ||
name: "Case #" + i, | ||
'test: bogus test - ': function() { | ||
Y.Assert.isTrue(true); | ||
} | ||
})); | ||
} | ||
for (i = 1; i <= 5; i++) { | ||
suite.add(new Y.Test.Case({ | ||
name: "Case #" + i, | ||
'test: bogus failed - ': function() { | ||
Y.Assert.isTrue(false); | ||
} | ||
})); | ||
} | ||
Y.Test.Runner.add(suite); | ||
Y.Test.Runner.run(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
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,25 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Test One</title> | ||
</head> | ||
<body> | ||
<script src="http://davglass.homelinux.com/yui/yui3/build/yui/yui-min.js"></script> | ||
<script> | ||
YUI().use('test', function(Y) { | ||
var suite = new Y.Test.Suite('Suite #1'); | ||
|
||
for (var i = 1; i <= 50; i++) { | ||
suite.add(new Y.Test.Case({ | ||
name: "Case #" + i, | ||
'test: bogus test - ': function() { | ||
Y.Assert.isTrue(true); | ||
} | ||
})); | ||
} | ||
Y.Test.Runner.add(suite); | ||
Y.Test.Runner.run(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
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,57 @@ | ||
#!/usr/bin/env node | ||
|
||
process.chdir(__dirname); | ||
|
||
var YUITest = require('yuitest'), | ||
path = require('path'), | ||
exec = require('child_process').exec; | ||
|
||
var Assert = YUITest.Assert; | ||
|
||
var wrapper = path.join(__dirname, '../lib/wrapper.js'); | ||
|
||
var runTest = function(file, cb) { | ||
var cmd = 'phantomjs ' + wrapper + ' ' + file; | ||
exec(cmd, cb); | ||
}; | ||
|
||
var suite = new YUITest.TestSuite('Grover'); | ||
|
||
suite.add(new YUITest.TestCase({ | ||
name: 'Good Results', | ||
'Check Results': function() { | ||
var test = this; | ||
|
||
runTest('./html/good.html', function(err, stdout) { | ||
test.resume(function() { | ||
var json = JSON.parse(stdout); | ||
Assert.areSame('Suite #1', json.name, 'Suite Name Incorrect'); | ||
Assert.areEqual(50, json.passed, 'A test failed'); | ||
Assert.areEqual(0, json.failed, 'A test failed'); | ||
}); | ||
}); | ||
|
||
this.wait(); | ||
} | ||
})); | ||
|
||
suite.add(new YUITest.TestCase({ | ||
name: 'Failed Results', | ||
'Failed Tests': function() { | ||
var test = this; | ||
|
||
runTest('./html/bad.html', function(err, stdout) { | ||
test.resume(function() { | ||
var json = JSON.parse(stdout); | ||
Assert.areSame('Suite Bad', json.name, 'Suite Name Incorrect'); | ||
Assert.areEqual(5, json.passed, 'A test failed'); | ||
Assert.areEqual(5, json.failed, 'A test failed'); | ||
}); | ||
}); | ||
|
||
this.wait(); | ||
} | ||
})); | ||
|
||
|
||
YUITest.TestRunner.add(suite); |