Authored by ccbikai

提高测试覆盖率

... ... @@ -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,
... ...
... ... @@ -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) => {
}
});
});
... ...
... ... @@ -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);
});
});
... ...
... ... @@ -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));
});
... ...