Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding initial tests

  • Loading branch information...
commit 0bc3a8c3466edc86ff3b9705b4d293fb038b0f0b 1 parent 8b3ab82
@davglass authored
View
6 package.json
@@ -11,5 +11,11 @@
"colors": "*",
"yuitest": "*"
},
+ "devDependencies": {
+ "yuitest": "*"
+ },
+ "scripts": {
+ "test": "./node_modules/.bin/yuitest ./tests/test.js"
+ },
"preferGlobal": "true"
}
View
BIN  tests/.test.js.swp
Binary file not shown
View
33 tests/html/bad.html
@@ -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>
View
25 tests/html/good.html
@@ -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>
View
57 tests/test.js
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.