// https://github.com/defunctzombie/zuul/issues/145 test('fail', function (t) { t.ok(false) t.end() })
test("fn.formatTime", t => { const fn = $.formatTime t.equal(fn([0, -1e6]), "-1ms", "accepts negative numbers") t.equal(fn([0, 0]), "0ms", "accepts zero") t.equal(fn([0, 0.999e9]), "999ms", "accepts positive number") t.equal(fn([1, 0]), "1.00s", "simple seconds") t.equal(fn([2, 2.2e7]), "2.02s", "converts large, quirky number") t.end() })
test('cli errors if providers is ' + JSON.stringify(input), function (t) { const cwd = tempy.directory() const config = input === undefined ? {} : { providers: input } writeConfig(cwd, { ...config }) exec(`node ${bin} test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim(), read('no-input.txt').trim()) t.end() }) })
test('session unknown message', function (t) { t.plan(2) const session = new BrowserSession('abc', 30e3, '.') session.on('error', function (err) { t.is(err.message, 'Unknown message type') }) session.on('close', function () { t.pass('closed') }) session.resume() session.write({ type: 'foo' }) })
test('@taskr/clear: directory', co(function * (t) { t.plan(1); yield create({ * a(f) { const src = `${dir1}/foo`; yield f.$.write(src); yield f.clear(dir1); t.false(exists(src), 'directory was deleted'); } }).start('a'); }));
test("Task.constructor (basic)", co(function * (t) { const taskr = new Taskr() const task = new Task(taskr) t.true($.isObject(task), "returns an object") protos.forEach(str => { t.true(task.hasOwnProperty(str), `Task.prototype.${str} is defined`) }) t.end() }))
test("fn.getTime", t => { const out = $.getTime() t.equal(typeof out, "string", "returns a string") t.equal(out.split(":").length, 3, "has 3 segments") t.equal(out.length, 10, "is always 10 characters long") t.end() })
test('@taskr/stylus', t => { t.plan(1); const taskr = create({ *foo(f) { t.true('stylus' in taskr.plugins, 'attach `stylus()` plugin to taskr'); } }); taskr.start('foo'); });
test("utils.find", co(function* (t) { const file = "taskfile.js" const full = join(fixtures, file) const out1 = yield $.find(file, fixtures) t.true(out1.length && typeof out1 === "string", "if found returns a string") t.equal(out1, full, `via directory path finds the correct taskfile`) const out2 = yield $.find(full) t.equal(out2, full, `via file path finds the correct taskfile`) const out4 = yield $.find(file, "/fakedir123") t.equal(out4, null, "if not found returns `null`") t.end() }))
test(function (t) { t.ok(false) t.notOk(true) t.equal('foo', 'bar') t.deepEqual({ foo: 1 }, { bar: 1 }) t.end() })
test("utils", t => { t.ok($ !== undefined, "are exported") const methods = [ "find", "read", "write", "expand", "error", "alert", "trace", "log", "promisify", "coroutine" ] methods.forEach(prop => { t.true($[prop] !== undefined, `utils.${prop} exists`) }) t.end() })
test("Task.constructor (plugins)", co(function * (t) { const taskr = new Taskr({ tasks: { *a(){} }, plugins: [{ name: "foo", *func(){} }] }) const task = new Task(taskr) t.true(task.hasOwnProperty("foo"), "inherits the `foo()` plugin") t.equal(typeof task.foo, "function", "mounts correctly as a function") t.end() }))
test('@taskr/prettier', t => { t.plan(2); const taskr = create({ *foo(f) { t.true('prettier' in f, 'attach `prettier` to Task instance'); t.true('prettier' in taskr.plugins, 'attach `prettier` plugin to instance'); } }); taskr.start('foo'); });
test("Taskr.prototype", t => { t.ok(Taskr !== undefined, "is defined") const cmds = [ "emit", "on", "plugin", "start", "serial", "parallel" ] cmds.forEach(cmd => { t.equal(typeof Taskr.prototype[cmd], "function", `Taskr.prototype.${cmd} is defined`) }) t.end() })
test(function (t) { t.ok(true) t.notOk(false) t.equal('foo', 'foo') t.deepEqual({ foo: 1 }, { foo: 1 }) t.end() })