lintry

拆分登录到before中,测试用例分成单个查询,链接查询

var chai = require('chai'),
should = require('should'),
chaiHttp = require('chai-http');
chai.use(chaiHttp);
var agent = chai.request.agent('http://onwall.cn');
var cookie;
describe('测试模块', function() {
var chai = require('chai'),
should = require('should'),
chaiHttp = require('chai-http');
chai.use(chaiHttp);
var agent = chai.request.agent('http://onwall.cn');
it('测试接口', function(done) {
// this.timeout(5000);
agent.post('/domino/b/auth_syslogin.do')
.send({user_code: 'IT001001DZ', user_password: '8ddcff3a80f4189ca1c9d4d902c3c909'})
.end(function(err, res) {
// 登录应该成功
try {
var result = JSON.parse(res.text);
} catch(e) {
console.error(e);
should.not.exist(e);
}
res.status.should.equal(200);
result.ret.should.equal('OK');
return agent.get('/domino/b/order_query.do')
before(function(done) {
agent.post('/domino/b/auth_syslogin.do')
.send({user_code: 'IT001001DZ', user_password: '8ddcff3a80f4189ca1c9d4d902c3c909'})
.end(function(err, res) {
// 登录应该成功
try {
var result = JSON.parse(res.text);
} catch(e) {
console.error(e);
should.not.exist(e);
}
res.status.should.equal(200);
result.ret.should.equal('OK');
done();
});
});
it('测试订单查询接口', function(done) {
agent.get('/domino/b/order_query.do')
.end(function(err, res) {
//返回值状态应该200且有OK
try {
......@@ -40,9 +44,53 @@ describe('测试模块', function() {
content.should.have.property('order_list');
content.order_list.length.should.aboveOrEqual(0);
done();
console.log('content is ', content);
}
);
});
it('测试门店列表-取第一个门店信息查看接口', function(done) {
agent.get('/domino/b/corp_listQuery.do')
.end(function(err, res) {
//返回值状态应该200且有OK
try {
var result = JSON.parse(res.text);
} catch(e) {
console.error(e);
should.not.exist(e);
}
res.status.should.equal(200);
result.ret.should.equal('OK');
//判断返回数据是否存在指定的属性或数值是否正确
let content = result.content;
content.should.have.property('corp_list');
content.corp_list.length.should.above(0);
let corp = content.corp_list[0];
return agent.get('/domino/b/corp_info.do')
.send({corp_id: corp.corp_id})
.end(function(err, res) {
//返回值状态应该200且有OK
try {
var result = JSON.parse(res.text);
} catch(e) {
console.error(e);
should.not.exist(e);
}
res.status.should.equal(200);
result.ret.should.equal('OK');
//判断返回数据是否存在指定的属性或数值是否正确
let content = result.content;
content.should.not.be.empty();
done();
console.log('corp is ', content);
}
);
}
);
});
})
});
......