Sha256: 47a708e0f595bc205e7bfdf0b018aa96b87d0fe88b41211083332aca76e29e51
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
// ========================================================================== // Project: SproutCore Unit Testing Library // Copyright: ©2006-2009 Sprout Systems, Inc. and contributors. // Portions ©2008-2009 Apple Inc. All rights reserved. // License: Licened under MIT license (see license.js) // ========================================================================== /*globals Ct */ require('./core'); var utils = require('./utils'); /** @namespace Just like CoreTest except we by default assume tests are async unless they return a promise or callback. */ exports = __module.exports= utils.beget(Ct); function sync(handler) { return function(t, done) { var ret = handler(t); // returns a continuable - invoke with done handler if ('function' === typeof ret) ret(done); // returns a promise - add listener else if (ret && ('function'===typeof ret.then)) { ret.then(function() { done(); }, function(e) { done(e); }); // sync - return result } else done(); }; } exports.module = function(moduleName, opts) { Ct.module(moduleName); if (opts && opts.setup) exports.setup(opts.setup); if (opts && opts.teardown) exports.teardown(opts.teardown); return this; }; exports.setup = function(handler) { Ct.setup(sync(handler)); return this; }; exports.teardown = function(handler) { Ct.teardown(sync(handler)); return this; }; exports.test = function(testName, handler) { // Do this here so it gets wrapped in sync. This is a bit redundant unfortunately. if (!handler) { handler = Ct.Test.PENDING_HANDLER; }; Ct.test(testName, sync(handler)); return this; }; ['run', 'then', 'assert', 'error', 'info'].forEach(function(key) { exports[key] = function() { Ct[key].apply(Ct, arguments); return this; }; });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spade-0.0.1 | packages/core-test/lib/sync.js |