test_template_by_chai-http.js
3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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() {
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 {
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('order_status_map');
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);
}
);
}
);
})
});