Toggle navigation
Toggle navigation
This project
Loading...
Sign in
test
/
demo-chai-http
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
lintry
2016-10-25 10:57:14 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2baeec122f0eff4babfe431fa7b3e57a707ea7da
2baeec12
1 parent
c1bade76
拆分登录到before中,测试用例分成单个查询,链接查询
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
24 deletions
test_template_by_chai-http.js
test_template_by_chai-http.js
View file @
2baeec1
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
);
}
);
}
);
});
})
});
...
...
Please
register
or
login
to post a comment