Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rework public API for defining tests

  • Loading branch information...
commit 76c57526f7a65a0b2e392c3608c4be35df786815 1 parent 7729b7d
@gschmidt gschmidt authored
View
2  packages/htmljs/htmljs_test.js
@@ -1,5 +1,5 @@
-test("htmljs", function (test) {
+Tinytest.add("htmljs", function (test) {
// Make sure "style" works, which has to be special-cased for IE.
test.equal(DIV({style:"display:none"}).style.display, "none");
View
4 packages/livedata/livedata_tests.js
@@ -58,7 +58,7 @@ _.extend(ExpectationManager.prototype, {
var testAsyncMulti = function (name, funcs) {
var timeout = 5000;
- testAsync(name, function (test, onComplete) {
+ Tinytest.addAsync(name, function (test, onComplete) {
var remaining = _.clone(funcs);
var runNext = function () {
@@ -111,7 +111,7 @@ var failure = function (test, code, reason) {
};
}
-test("livedata - methods with colliding names", function (test) {
+Tinytest.add("livedata - methods with colliding names", function (test) {
var x = LocalCollection.uuid();
var m = {};
m[x] = function () {};
View
8 packages/liveui/liverange_tests.js
@@ -88,7 +88,7 @@ var assert_contained = function (r, expected) {
/******************************************************************************/
-test("liverange - single node", function (test) {
+Tinytest.add("liverange - single node", function (test) {
var f = frag("<div id=1></div>");
var r_a = create("a", f);
test.instanceOf(r_a, Meteor.ui._LiveRange);
@@ -158,7 +158,7 @@ test("liverange - single node", function (test) {
assert_dump(test, "<c><3></3></c>", r_c);
});
-test("liverange - multiple nodes", function (test) {
+Tinytest.add("liverange - multiple nodes", function (test) {
var f = frag("<div id=1></div><div id=2></div><div id=3></div><div id=4></div><div id=5></div>");
assert_dump(test, "<1></1><2></2><3></3><4></4><5></5>", f);
@@ -279,7 +279,7 @@ test("liverange - multiple nodes", function (test) {
assert_dump(test, "<6></6><7><1></1><9></9><10></10><11></11><5></5></7><8></8>", f2);
});
-test("liverange - deep visit", function (test) {
+Tinytest.add("liverange - deep visit", function (test) {
var f = frag("<div id=1><div id=2><div id=3><div id=4><div id=5></div></div></div></div></div>");
@@ -301,7 +301,7 @@ test("liverange - deep visit", function (test) {
{range: r_d, children: [{range: r_c, children: [{range: r_b, children: [{range: r_a, children: []}]}]}]});
});
-test("liverange - create inner", function (test) {
+Tinytest.add("liverange - create inner", function (test) {
// Basics
var f = frag("<div id=1></div><div id=2></div><div id=3></div><div id=4></div><div id=5></div>");
View
24 packages/liveui/liveui_tests.js
@@ -66,7 +66,7 @@ var set_weather = function (where, what) {
// XXX SECTION: LiveUI
-test("render - coercion", function (test) {
+Tinytest.add("render - coercion", function (test) {
assert_frag(test, "<a></a>", Meteor.ui.render(function () {
return DIV({id: "a"});
@@ -103,7 +103,7 @@ test("render - coercion", function (test) {
}));
});
-test("render - updating and GC", function (test) {
+Tinytest.add("render - updating and GC", function (test) {
set_weather("here", "cloudy");
test.length(_.keys(weather_listeners.here), 0);
var r = Meteor.ui.render(function () {
@@ -155,7 +155,7 @@ test("render - updating and GC", function (test) {
assert_frag(test, "~curious~", onscreen);
});
-test("render - recursive", function (test) {
+Tinytest.add("render - recursive", function (test) {
set_weather("there", "wet");
var outer_count = 0;
@@ -216,7 +216,7 @@ test("render - recursive", function (test) {
test.length(_.keys(weather_listeners.there), 0);
});
-test("render - events", function (test) {
+Tinytest.add("render - events", function (test) {
var evts = '';
var onscreen = DIV({style: "display: none;"}, [
Meteor.ui.render(function () {
@@ -346,7 +346,7 @@ test("render - events", function (test) {
document.body.removeChild(onscreen);
});
-test("renderList - basics", function (test) {
+Tinytest.add("renderList - basics", function (test) {
var c = new LocalCollection();
var r = Meteor.ui.renderList(c.find({}, {sort: ['id']}), {
@@ -412,7 +412,7 @@ test("renderList - basics", function (test) {
assert_frag(test, "<C2></C2><D></D><D2></D2><E2></E2><F2></F2>", r);
});
-test("renderList - removal", function (test) {
+Tinytest.add("renderList - removal", function (test) {
var c = new LocalCollection();
// (test is written in this weird way for historical reasons; feel
// free to refactor)
@@ -474,7 +474,7 @@ test("renderList - removal", function (test) {
);
});
-test("renderList - default render empty", function (test) {
+Tinytest.add("renderList - default render empty", function (test) {
var c = new LocalCollection();
var r = Meteor.ui.renderList(c.find({}, {sort: ['id']}), {
@@ -490,7 +490,7 @@ test("renderList - default render empty", function (test) {
assert_frag(test, "<!---->", r);
});
-test("renderList - change and move", function (test) {
+Tinytest.add("renderList - change and move", function (test) {
var c = new LocalCollection();
var r = Meteor.ui.renderList(c.find({}, {sort: ['id']}), {
@@ -522,7 +522,7 @@ test("renderList - change and move", function (test) {
assert_frag(test, "<C></C><D></D><E></E><F></F>", r);
});
-test("renderList - termination", function (test) {
+Tinytest.add("renderList - termination", function (test) {
var c = new LocalCollection();
var r = Meteor.ui.renderList(c.find({}, {sort: ['id']}), {
@@ -613,7 +613,7 @@ test("renderList - termination", function (test) {
);
});
-test("renderList - list items are reactive", function (test) {
+Tinytest.add("renderList - list items are reactive", function (test) {
var c = new LocalCollection();
set_weather("here", "cloudy");
@@ -736,7 +736,7 @@ test("renderList - list items are reactive", function (test) {
assert_frag(test, "<C></C><D_sunny></D_sunny><E></E><F_cloudy></F_cloudy>", onscreen);
});
-test("renderList - multiple elements in an item", function (test) {
+Tinytest.add("renderList - multiple elements in an item", function (test) {
var c = new LocalCollection();
var r;
@@ -832,7 +832,7 @@ test("renderList - multiple elements in an item", function (test) {
);
});
-test("renderList - #each", function (test) {
+Tinytest.add("renderList - #each", function (test) {
var c = new LocalCollection();
var render_count = 0;
View
2  packages/logging/logging_test.js
@@ -1,4 +1,4 @@
-test("logging", function (test) {
+Tinytest.add("logging", function (test) {
// Just run a log statement and make sure it doesn't explode.
Meteor._debug();
View
2  packages/meteor/client_environment_test.js
@@ -1,4 +1,4 @@
-test("environment - client basics", function (test) {
+Tinytest.add("environment - client basics", function (test) {
test.isTrue(Meteor.is_client);
test.isFalse(Meteor.is_server);
});
View
7 packages/meteor/dynamics_test.js
@@ -1,6 +1,6 @@
CurrentFoo = new Meteor.DynamicVariable;
-test("environment - dynamic variables", function (test) {
+Tinytest.add("environment - dynamic variables", function (test) {
test.equal(CurrentFoo.get(), undefined);
CurrentFoo.withValue(17, function () {
@@ -16,7 +16,7 @@ test("environment - dynamic variables", function (test) {
test.equal(CurrentFoo.get(), undefined);
});
-test("environment - bindEnvironment", function (test) {
+Tinytest.add("environment - bindEnvironment", function (test) {
var raised_f;
var f = CurrentFoo.withValue(17, function () {
@@ -97,7 +97,8 @@ test("environment - bindEnvironment", function (test) {
test.equal(CurrentFoo.get(), undefined);
});
-testAsync("environment - bare bindEnvironment", function (test, onComplete) {
+Tinytest.addAsync("environment - bare bindEnvironment",
+ function (test, onComplete) {
// this will have to create a fiber in nodejs
CurrentFoo.withValue(68, function () {
var f = Meteor.bindEnvironment(function () {
View
2  packages/meteor/server_environment_test.js
@@ -1,4 +1,4 @@
-test("environment - server basics", function (test) {
+Tinytest.add("environment - server basics", function (test) {
test.isFalse(Meteor.is_client);
test.isTrue(Meteor.is_server);
});
View
16 packages/minimongo/minimongo_tests.js
@@ -37,7 +37,7 @@ assert_ordering = function (test, f, values) {
// XXX test shared structure in all MM entrypoints
-test("minimongo - basics", function (test) {
+Tinytest.add("minimongo - basics", function (test) {
var c = new LocalCollection();
c.insert({type: "kitten", name: "fluffy"});
@@ -128,7 +128,7 @@ test("minimongo - basics", function (test) {
expect("aa4_");
});
-test("minimongo - cursors", function (test) {
+Tinytest.add("minimongo - cursors", function (test) {
var c = new LocalCollection();
var res;
@@ -172,7 +172,7 @@ test("minimongo - cursors", function (test) {
test.equal(c.findOne(id).i, 2);
});
-test("minimongo - misc", function (test) {
+Tinytest.add("minimongo - misc", function (test) {
// deepcopy
var a = {a: [1, 2, 3], b: "x", c: true, d: {x: 12, y: [12]},
f: null};
@@ -194,7 +194,7 @@ test("minimongo - misc", function (test) {
test.equal(b.x.a, 14); // just to document current behavior
});
-test("minimongo - selector_compiler", function (test) {
+Tinytest.add("minimongo - selector_compiler", function (test) {
var matches = function (should_match, selector, doc) {
var does_match = LocalCollection._matches(selector, doc);
if (does_match != should_match) {
@@ -506,7 +506,7 @@ test("minimongo - selector_compiler", function (test) {
// - non-scalar arguments to $gt, $lt, etc
});
-test("minimongo - ordering", function (test) {
+Tinytest.add("minimongo - ordering", function (test) {
// value ordering
assert_ordering(test, LocalCollection._f._cmp, [
null,
@@ -549,7 +549,7 @@ test("minimongo - ordering", function (test) {
test.equal(LocalCollection._compileSort({})({a:1}, {a:2}), 0);
});
-test("minimongo - sort", function (test) {
+Tinytest.add("minimongo - sort", function (test) {
var c = new LocalCollection();
for (var i = 0; i < 50; i++)
for (var j = 0; j < 2; j++)
@@ -580,7 +580,7 @@ test("minimongo - sort", function (test) {
{a: 47, b: 1, _id: "47_1"}]);
});
-test("minimongo - modify", function (test) {
+Tinytest.add("minimongo - modify", function (test) {
var modify = function (doc, mod, result) {
var copy = LocalCollection._deepcopy(doc);
LocalCollection._modify(copy, mod);
@@ -824,7 +824,7 @@ test("minimongo - modify", function (test) {
// XXX test update() (selecting docs, multi, upsert..)
-test("minimongo - observe", function (test) {
+Tinytest.add("minimongo - observe", function (test) {
var operations = [];
var cbs = {
added: function (obj, idx) {
View
2  packages/stream/stream_tests.js
@@ -1,4 +1,4 @@
-test("stream - status", function (test) {
+Tinytest.add("stream - status", function (test) {
// Very basic test. Just see that it runs and returns something. Not a
// lot of coverage, but enough that it would have caught a recent bug.
var status = Meteor.status();
View
4 packages/templating/templating_tests.js
@@ -1,5 +1,5 @@
-test("template assembly", function (test) {
+Tinytest.add("template assembly", function (test) {
var minusEmptyComments = function(s) {
return String(s).replace(/<!---->/g, '');
};
@@ -32,7 +32,7 @@ test("template assembly", function (test) {
-test("template table assembly", function(test) {
+Tinytest.add("template table assembly", function(test) {
var childWithTag = function(node, tag) {
return _.find(node.childNodes, function(n) {
return n.nodeName === tag;
View
2  packages/test-helpers/try_all_permutations_test.js
@@ -1,6 +1,6 @@
// XXX SECTION: Meta tests
-test("try_all_permutations", function (test) {
+Tinytest.add("try_all_permutations", function (test) {
// Have a good test of try_all_permutations, because it would suck
// if try_all_permutations didn't actually run anything and so none
// of our other tests actually did any testing.
View
16 packages/tinytest/tinytest.js
@@ -313,16 +313,14 @@ _.extend(TestRun.prototype, {
/******************************************************************************/
var globals = this;
+globals.Tinytest = {
+ add: function (name, func) {
+ TestManager.addCase(new TestCase(name, func));
+ },
-// XXX this API is confusing and irregular. revisit once we have
-// package namespacing.
-
-globals.test = function (name, func) {
- TestManager.addCase(new TestCase(name, func));
-};
-
-globals.testAsync = function (name, func) {
- TestManager.addCase(new TestCase(name, func, true));
+ addAsync: function (name, func) {
+ TestManager.addCase(new TestCase(name, func, true));
+ }
};
// Run every test, asynchronously. Runs the test in the current
Please sign in to comment.
Something went wrong with that request. Please try again.