MCPcopy
hub / github.com/yortus/asyncawait / runTestsFor

Function runTestsFor

test/async.js:7–38  ·  view source on GitHub ↗
(variant, acceptsCallback)

Source from the content-addressed store, hash-verified

5var expect = chai.expect;
6//TODO: tests for long stack traces across async calls?
7function runTestsFor(variant, acceptsCallback) {
8 if (acceptsCallback === void 0) { acceptsCallback = false; }
9 var name = 'async' + (variant ? ('.' + variant) : '');
10 var func = async;
11 if (variant)
12 variant.split('.').forEach(function (prop) { return func = func[prop]; });
13 var arity = function (fn) { return fn.length + (acceptsCallback ? 1 : 0); };
14 describe('The ' + name + '(...) function', function () {
15 //it('throws if not passed a single function', () => {
16 // expect(() => func.call(func, 1)).to.throw(Error);
17 // expect(() => func.call(func, 'sss')).to.throw(Error);
18 // expect(() => func.call(func, ()=>{}, true)).to.throw(Error);
19 // expect(() => func.call(func, ()=>{}, ()=>{})).to.throw(Error);
20 //});
21 it('synchronously returns a function', function () {
22 var foo = func(function () { });
23 expect(foo).to.be.a('function');
24 });
25 it('returns a function whose arity matches that of its definition', function () {
26 var defns = [
27 function (a, b, c) { },
28 function () { },
29 function (a, b, c, d, e, f, g, h) { },
30 function (x) { }
31 ];
32 for (var i = 0; i < defns.length; ++i) {
33 var foo = func(defns[i]);
34 expect(foo.length).to.equal(arity(defns[i]));
35 }
36 });
37 });
38}
39runTestsFor(null);
40runTestsFor('cps', true);
41runTestsFor('thunk');

Callers 1

async.jsFile · 0.70

Calls 3

equalMethod · 0.80
arityFunction · 0.70
forEachMethod · 0.65

Tested by

no test coverage detected