app.get('/', function (req, res) { expect(req.headers['user-agent']).toMatch(/iphone/i); expect(req.headers['host']).toMatch(/localhost/); expect(req.headers['origin']).toMatch(/localhost/); expect(req.headers['referer']).toMatch(/localhost/); res.send('ok'); });
.try(function (ret1, ret2, ret3, ret4) { expect(ret1).toBe(1); expect(ret2).toBe(2); expect(ret3).toBe(3); expect(ret4).toBe(4); done(); });
app.get('/', function (req, res) { expect(req.headers['user-agent']).toEqual('a'); expect(req.headers['host']).toEqual('b'); expect(req.headers['origin']).toEqual('c'); expect(req.headers['referer']).toEqual('d'); res.send('ok'); });
it('有异步任务没有调 next', function () { expect(function () { plan.task(function () { }).serial(); }).toThrowError(); });
.try(function (ret) { expect(ret).toBe(undefined); });
plan.wait(10).serial(function () { expect(called).toBeTruthy(); done(); });
plan.wait(10).taskSync(function () { expect(called).toBeTruthy(); }).serial(done);
.catch(function (err) { expect(err.message).toMatch(/is 2/); expect(times).toBe(0); done(); });
plan.wait(10).serial(function (err) { expect(err).toBeNull(); }).on('planEnd', function (err, ret) {
}, function (err, body) { expect(body).toEqual('ok'); stop(); });
}, function (err) { expect(err).toBeTruthy(); stop(); });
}, function (err, buffer) { expect(Buffer.isBuffer(buffer)).toBe(true); stop(); });
app.get('/', function (req, res) { expect(req.query.a).toEqual('1'); expect(req.query.b).toEqual('2'); res.send('ok'); });
.taskSync(function () { expect(ret1).toBe(1); expect(ret2).toBe(undefined); })
.end(function (err, res) { if (err) throw err; expect(res.text).toEqual('AaA'); next(); });
plan.wait(50).serial(function () { expect(ret1).toBe(1); done(); });
.catch(function (err) { expect(err.message).toBe('3'); done(); });
}).on('planEnd', function (err, ret) { expect(this.length).toBe(1); done(); });
.end(function (err, res) { if (err) throw err; expect(res.text).toMatch(/=============================/); next(); });
.try(function (ret) { expect(ret).toBe(6); done(); });
it('exports', function () { expect(index).toEqual('index'); });