Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
ccbikai
9 years ago
Commit
9dbb5806f63e44ef313fd365a5dd5e86daf076fb
1 parent
fbda2b6e
提高测试覆盖率
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
21 deletions
package.json
test/library/api.test.js
test/library/cache.test.js
test/library/sign.test.js
package.json
View file @
9dbb580
...
...
@@ -15,7 +15,8 @@
"lint-js"
:
"./node_modules/.bin/eslint -c .eslintrc --cache --fix ."
,
"lint-css"
:
"./node_modules/.bin/stylelint --config .stylelintrc public/scss/**/*.css"
,
"precommit"
:
"node lint.js"
,
"test"
:
"./node_modules/.bin/nyc ./node_modules/.bin/ava"
"test"
:
"NODE_ENV=test ./node_modules/.bin/nyc ./node_modules/.bin/ava"
,
"posttest"
:
"./node_modules/.bin/nyc report --reporter=html"
},
"ava"
:
{
"tap"
:
true
,
...
...
test/library/api.test.js
View file @
9dbb580
...
...
@@ -7,14 +7,8 @@
'use strict'
;
const
test
=
require
(
'ava'
);
// const rewire = require('rewire');
// const shelljs = require('shelljs');
const
sign
=
require
(
'../../library/sign'
);
// let config = rewire('../../config/common');
const
API
=
require
(
'../../library/api'
).
API
;
const
ServiceAPI
=
require
(
'../../library/api'
).
ServiceAPI
;
...
...
@@ -22,17 +16,6 @@ const SearchAPI = require('../../library/api').SearchAPI;
const
getUrl
=
'operations/api/v6/category/getCategory'
;
// test.before('create log folder', (t) => {
// shelljs.mkdir('log');
// t.pass();
// });
//
// test.after('delete log folder', (t) => {
// shelljs.rm('-rf', 'log');
// t.pass();
// });
test
(
'api constructor test'
,
(
t
)
=>
{
let
api
=
new
ServiceAPI
();
let
api2
=
new
API
();
...
...
@@ -103,5 +86,3 @@ test('api multiple fail call test', (t) => {
}
});
});
...
...
test/library/cache.test.js
View file @
9dbb580
...
...
@@ -40,7 +40,6 @@ test('cache get test', (t) => {
test
(
'cache get multi test'
,
(
t
)
=>
{
cache
.
set
(
anotherKey
,
anotherValue
);
return
cache
.
getMulti
([
testKey
,
anotherKey
]).
then
((
values
)
=>
{
console
.
log
(
values
);
t
.
is
(
values
[
testKey
],
testValue
);
t
.
is
(
values
[
anotherKey
],
JSON
.
stringify
(
anotherValue
));
});
...
...
@@ -68,3 +67,45 @@ test('cache set to slave', (t) => {
cache
.
del
(
slaveTestKey
);
});
});
test
(
'cache get test, key is not a string'
,
(
t
)
=>
{
return
cache
.
get
(
123
).
then
((
v
)
=>
{
t
.
notOk
(
v
);
});
});
test
(
'cache get multi test, key is not an array'
,
(
t
)
=>
{
return
cache
.
getMulti
(
123
).
then
((
v
)
=>
{
t
.
notOk
(
v
);
});
});
test
(
'cache get from slave test, key is not a string'
,
(
t
)
=>
{
return
cache
.
getFromSlave
(
123
).
then
((
v
)
=>
{
t
.
notOk
(
v
);
});
});
test
(
'cache get multi from slave test, key is not an array'
,
(
t
)
=>
{
return
cache
.
getMultiFromSlave
(
123
).
then
((
v
)
=>
{
t
.
notOk
(
v
);
});
});
test
(
'cache set test, key is not a string'
,
(
t
)
=>
{
return
cache
.
set
(
123
).
then
((
v
)
=>
{
t
.
notOk
(
v
);
});
});
test
(
'cache set multi test, key is not an array'
,
(
t
)
=>
{
return
cache
.
setSlave
(
123
).
then
((
v
)
=>
{
t
.
notOk
(
v
);
});
});
test
(
'cache del test, key is not a string'
,
(
t
)
=>
{
return
cache
.
del
(
123
).
then
((
v
)
=>
{
t
.
notOk
(
v
);
});
});
...
...
test/library/sign.test.js
View file @
9dbb580
...
...
@@ -18,3 +18,12 @@ test('app sign test', t => {
t
.
true
(
sign
.
checkSign
(
signedParams
));
});
test
(
'app sign test webSign'
,
t
=>
{
let
params
=
{
uid
:
'123'
,
key
:
'3fc5a9fcea9fea49cce5432202a167ad'
};
t
.
true
(
sign
.
webSign
(
params
));
});
...
...
Please
register
or
login
to post a comment