mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
test(validate) coverage
This commit is contained in:
parent
18080f878f
commit
57c57b7243
1 changed files with 22 additions and 1 deletions
|
|
@ -9,12 +9,13 @@ const tryCatch = require('try-catch');
|
|||
const mockRequire = require('mock-require');
|
||||
const {reRequire} = mockRequire;
|
||||
|
||||
const dir = '../..';
|
||||
const dir = '..';
|
||||
|
||||
const validatePath = `${dir}/server/validate`;
|
||||
const exitPath = `${dir}/server/exit`;
|
||||
const columnsPath = `${dir}/server/columns`;
|
||||
const cloudcmdPath = `${dir}/server/cloudcmd`;
|
||||
const configPath = `${dir}/server/config`;
|
||||
|
||||
const validate = require(validatePath);
|
||||
const cloudcmd = require(cloudcmdPath);
|
||||
|
|
@ -29,6 +30,26 @@ test('validate: root: bad', (t) => {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('validate: root: config', (t) => {
|
||||
const config = {
|
||||
root: Math.random()
|
||||
};
|
||||
|
||||
const configFn = sinon
|
||||
.stub()
|
||||
.returns(true);
|
||||
|
||||
mockRequire(configPath, configFn);
|
||||
|
||||
const validate = reRequire(validatePath);
|
||||
validate.root('/hello');
|
||||
|
||||
mockRequire.stop(configPath);
|
||||
|
||||
t.ok(configFn.calledWith('dropbox'), 'should call config');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('validate: root: /', (t) => {
|
||||
const fn = sinon.stub();
|
||||
validate.root('/', fn);
|
||||
Loading…
Add table
Add a link
Reference in a new issue