Showing
1 changed file
with
55 additions
and
7 deletions
| 1 | -describe('测试模块', function() { | 1 | +var chai = require('chai'), |
| 2 | - var chai = require('chai'), | ||
| 3 | should = require('should'), | 2 | should = require('should'), |
| 4 | chaiHttp = require('chai-http'); | 3 | chaiHttp = require('chai-http'); |
| 5 | 4 | ||
| 6 | - chai.use(chaiHttp); | 5 | +chai.use(chaiHttp); |
| 7 | - var agent = chai.request.agent('http://onwall.cn'); | 6 | +var agent = chai.request.agent('http://onwall.cn'); |
| 7 | +var cookie; | ||
| 8 | 8 | ||
| 9 | - it('测试接口', function(done) { | 9 | +describe('测试模块', function() { |
| 10 | - // this.timeout(5000); | 10 | + before(function(done) { |
| 11 | agent.post('/domino/b/auth_syslogin.do') | 11 | agent.post('/domino/b/auth_syslogin.do') |
| 12 | .send({user_code: 'IT001001DZ', user_password: '8ddcff3a80f4189ca1c9d4d902c3c909'}) | 12 | .send({user_code: 'IT001001DZ', user_password: '8ddcff3a80f4189ca1c9d4d902c3c909'}) |
| 13 | .end(function(err, res) { | 13 | .end(function(err, res) { |
| ... | @@ -20,8 +20,12 @@ describe('测试模块', function() { | ... | @@ -20,8 +20,12 @@ describe('测试模块', function() { |
| 20 | } | 20 | } |
| 21 | res.status.should.equal(200); | 21 | res.status.should.equal(200); |
| 22 | result.ret.should.equal('OK'); | 22 | result.ret.should.equal('OK'); |
| 23 | + done(); | ||
| 24 | + }); | ||
| 25 | + }); | ||
| 23 | 26 | ||
| 24 | - return agent.get('/domino/b/order_query.do') | 27 | + it('测试订单查询接口', function(done) { |
| 28 | + agent.get('/domino/b/order_query.do') | ||
| 25 | .end(function(err, res) { | 29 | .end(function(err, res) { |
| 26 | //返回值状态应该200且有OK | 30 | //返回值状态应该200且有OK |
| 27 | try { | 31 | try { |
| ... | @@ -40,9 +44,53 @@ describe('测试模块', function() { | ... | @@ -40,9 +44,53 @@ describe('测试模块', function() { |
| 40 | content.should.have.property('order_list'); | 44 | content.should.have.property('order_list'); |
| 41 | content.order_list.length.should.aboveOrEqual(0); | 45 | content.order_list.length.should.aboveOrEqual(0); |
| 42 | done(); | 46 | done(); |
| 47 | + console.log('content is ', content); | ||
| 43 | } | 48 | } |
| 44 | ); | 49 | ); |
| 45 | }); | 50 | }); |
| 51 | + | ||
| 52 | + it('测试门店列表-取第一个门店信息查看接口', function(done) { | ||
| 53 | + agent.get('/domino/b/corp_listQuery.do') | ||
| 54 | + .end(function(err, res) { | ||
| 55 | + //返回值状态应该200且有OK | ||
| 56 | + try { | ||
| 57 | + var result = JSON.parse(res.text); | ||
| 58 | + } catch(e) { | ||
| 59 | + console.error(e); | ||
| 60 | + should.not.exist(e); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + res.status.should.equal(200); | ||
| 64 | + result.ret.should.equal('OK'); | ||
| 65 | + | ||
| 66 | + //判断返回数据是否存在指定的属性或数值是否正确 | ||
| 67 | + let content = result.content; | ||
| 68 | + content.should.have.property('corp_list'); | ||
| 69 | + content.corp_list.length.should.above(0); | ||
| 70 | + let corp = content.corp_list[0]; | ||
| 71 | + return agent.get('/domino/b/corp_info.do') | ||
| 72 | + .send({corp_id: corp.corp_id}) | ||
| 73 | + .end(function(err, res) { | ||
| 74 | + //返回值状态应该200且有OK | ||
| 75 | + try { | ||
| 76 | + var result = JSON.parse(res.text); | ||
| 77 | + } catch(e) { | ||
| 78 | + console.error(e); | ||
| 79 | + should.not.exist(e); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + res.status.should.equal(200); | ||
| 83 | + result.ret.should.equal('OK'); | ||
| 84 | + | ||
| 85 | + //判断返回数据是否存在指定的属性或数值是否正确 | ||
| 86 | + let content = result.content; | ||
| 87 | + content.should.not.be.empty(); | ||
| 88 | + done(); | ||
| 89 | + console.log('corp is ', content); | ||
| 90 | + } | ||
| 91 | + ); | ||
| 92 | + } | ||
| 93 | + ); | ||
| 46 | }) | 94 | }) |
| 47 | 95 | ||
| 48 | }); | 96 | }); | ... | ... |
-
Please register or login to post a comment