Showing
4 changed files
with
53 additions
and
21 deletions
@@ -15,7 +15,8 @@ | @@ -15,7 +15,8 @@ | ||
15 | "lint-js": "./node_modules/.bin/eslint -c .eslintrc --cache --fix .", | 15 | "lint-js": "./node_modules/.bin/eslint -c .eslintrc --cache --fix .", |
16 | "lint-css": "./node_modules/.bin/stylelint --config .stylelintrc public/scss/**/*.css", | 16 | "lint-css": "./node_modules/.bin/stylelint --config .stylelintrc public/scss/**/*.css", |
17 | "precommit": "node lint.js", | 17 | "precommit": "node lint.js", |
18 | - "test": "./node_modules/.bin/nyc ./node_modules/.bin/ava" | 18 | + "test": "NODE_ENV=test ./node_modules/.bin/nyc ./node_modules/.bin/ava", |
19 | + "posttest": "./node_modules/.bin/nyc report --reporter=html" | ||
19 | }, | 20 | }, |
20 | "ava": { | 21 | "ava": { |
21 | "tap": true, | 22 | "tap": true, |
@@ -7,14 +7,8 @@ | @@ -7,14 +7,8 @@ | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | const test = require('ava'); | 9 | const test = require('ava'); |
10 | - | ||
11 | -// const rewire = require('rewire'); | ||
12 | - | ||
13 | -// const shelljs = require('shelljs'); | ||
14 | const sign = require('../../library/sign'); | 10 | const sign = require('../../library/sign'); |
15 | 11 | ||
16 | -// let config = rewire('../../config/common'); | ||
17 | - | ||
18 | 12 | ||
19 | const API = require('../../library/api').API; | 13 | const API = require('../../library/api').API; |
20 | const ServiceAPI = require('../../library/api').ServiceAPI; | 14 | const ServiceAPI = require('../../library/api').ServiceAPI; |
@@ -22,17 +16,6 @@ const SearchAPI = require('../../library/api').SearchAPI; | @@ -22,17 +16,6 @@ const SearchAPI = require('../../library/api').SearchAPI; | ||
22 | 16 | ||
23 | const getUrl = 'operations/api/v6/category/getCategory'; | 17 | const getUrl = 'operations/api/v6/category/getCategory'; |
24 | 18 | ||
25 | - | ||
26 | -// test.before('create log folder', (t) => { | ||
27 | -// shelljs.mkdir('log'); | ||
28 | -// t.pass(); | ||
29 | -// }); | ||
30 | -// | ||
31 | -// test.after('delete log folder', (t) => { | ||
32 | -// shelljs.rm('-rf', 'log'); | ||
33 | -// t.pass(); | ||
34 | -// }); | ||
35 | - | ||
36 | test('api constructor test', (t) => { | 19 | test('api constructor test', (t) => { |
37 | let api = new ServiceAPI(); | 20 | let api = new ServiceAPI(); |
38 | let api2 = new API(); | 21 | let api2 = new API(); |
@@ -103,5 +86,3 @@ test('api multiple fail call test', (t) => { | @@ -103,5 +86,3 @@ test('api multiple fail call test', (t) => { | ||
103 | } | 86 | } |
104 | }); | 87 | }); |
105 | }); | 88 | }); |
106 | - | ||
107 | - |
@@ -40,7 +40,6 @@ test('cache get test', (t) => { | @@ -40,7 +40,6 @@ test('cache get test', (t) => { | ||
40 | test('cache get multi test', (t) => { | 40 | test('cache get multi test', (t) => { |
41 | cache.set(anotherKey, anotherValue); | 41 | cache.set(anotherKey, anotherValue); |
42 | return cache.getMulti([testKey, anotherKey]).then((values) => { | 42 | return cache.getMulti([testKey, anotherKey]).then((values) => { |
43 | - console.log(values); | ||
44 | t.is(values[testKey], testValue); | 43 | t.is(values[testKey], testValue); |
45 | t.is(values[anotherKey], JSON.stringify(anotherValue)); | 44 | t.is(values[anotherKey], JSON.stringify(anotherValue)); |
46 | }); | 45 | }); |
@@ -68,3 +67,45 @@ test('cache set to slave', (t) => { | @@ -68,3 +67,45 @@ test('cache set to slave', (t) => { | ||
68 | cache.del(slaveTestKey); | 67 | cache.del(slaveTestKey); |
69 | }); | 68 | }); |
70 | }); | 69 | }); |
70 | + | ||
71 | +test('cache get test, key is not a string', (t) => { | ||
72 | + return cache.get(123).then((v) => { | ||
73 | + t.notOk(v); | ||
74 | + }); | ||
75 | +}); | ||
76 | + | ||
77 | +test('cache get multi test, key is not an array', (t) => { | ||
78 | + return cache.getMulti(123).then((v) => { | ||
79 | + t.notOk(v); | ||
80 | + }); | ||
81 | +}); | ||
82 | + | ||
83 | +test('cache get from slave test, key is not a string', (t) => { | ||
84 | + return cache.getFromSlave(123).then((v) => { | ||
85 | + t.notOk(v); | ||
86 | + }); | ||
87 | +}); | ||
88 | + | ||
89 | +test('cache get multi from slave test, key is not an array', (t) => { | ||
90 | + return cache.getMultiFromSlave(123).then((v) => { | ||
91 | + t.notOk(v); | ||
92 | + }); | ||
93 | +}); | ||
94 | + | ||
95 | +test('cache set test, key is not a string', (t) => { | ||
96 | + return cache.set(123).then((v) => { | ||
97 | + t.notOk(v); | ||
98 | + }); | ||
99 | +}); | ||
100 | + | ||
101 | +test('cache set multi test, key is not an array', (t) => { | ||
102 | + return cache.setSlave(123).then((v) => { | ||
103 | + t.notOk(v); | ||
104 | + }); | ||
105 | +}); | ||
106 | + | ||
107 | +test('cache del test, key is not a string', (t) => { | ||
108 | + return cache.del(123).then((v) => { | ||
109 | + t.notOk(v); | ||
110 | + }); | ||
111 | +}); |
@@ -18,3 +18,12 @@ test('app sign test', t => { | @@ -18,3 +18,12 @@ test('app sign test', t => { | ||
18 | 18 | ||
19 | t.true(sign.checkSign(signedParams)); | 19 | t.true(sign.checkSign(signedParams)); |
20 | }); | 20 | }); |
21 | + | ||
22 | +test('app sign test webSign', t => { | ||
23 | + let params = { | ||
24 | + uid: '123', | ||
25 | + key: '3fc5a9fcea9fea49cce5432202a167ad' | ||
26 | + }; | ||
27 | + | ||
28 | + t.true(sign.webSign(params)); | ||
29 | +}); |
-
Please register or login to post a comment