-
Notifications
You must be signed in to change notification settings - Fork 73
test suite #2
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
Comments
I wrote some tests using Mocha (see juandopazo@213ada3), but the issue is that since Task catches errors in the generator function there is no clear way to get Mocha to show the correct assertion failures. Would you be interested in using YUI Test? It uses a 'task should retrieve a promise\'s value': function () {
var test = this,
expected = 'hello world';
spawn(function () {
var actual = yield Promise.resolve(expected);
test.resume(function () {
Assert.areSame(expected, actual);
});
});
test.wait();
} |
Tests using YUI: juandopazo@bc26447. Another option could be Jasmine. Jasmine tests look very similar to Mocha, but they also provide their own context for assertions through a it('task should retrieve a promise\'s value': function () {
var done = false;
var someString = 'hello world';
var value;
runs(function () {
spawn(function () {
value = yield Promise.resolve(someString);
done = true;
});
});
waitsFor(function () {
return done == true;
});
runs(function () {
expect(value).to.eql(someString);
});
}); |
Fwiw, using doh (dojo's test harness) deferreds, the above test would look something like: function testReturnValue() {
var expected = "hello world",
deferred = new doh.Deferred();
spawn(deferred.getTestCallback(function() {
var actual = yield Promise.resolve(expected);
doh.assertEqual(expected, actual);
}));
return deferred;
} Disclaimer: I just happened to be following this thread, and haven't tested the above code at all. |
The problem with that version is that |
Oh right. Then without the convenience of function testReturnValue() {
var expected = "hello world",
deferred = new doh.Deferred();
spawn(function() {
try {
var actual = yield Promise.resolve(expected);
doh.assertEqual(expected, actual);
deferred.callback(true);
} catch (e) {
deferred.errback(e);
}
}));
return deferred;
} |
Need to choose a testing framework and set up a test suite.
The text was updated successfully, but these errors were encountered: