mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
test(plugins) coverage
This commit is contained in:
parent
c3bbc05f8d
commit
fa6de0ce67
2 changed files with 37 additions and 2 deletions
|
|
@ -1,70 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const test = require('supertape');
|
||||
const cloudcmd = require('..');
|
||||
|
||||
const config = {
|
||||
auth: false,
|
||||
};
|
||||
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
config,
|
||||
});
|
||||
|
||||
test('cloudcmd: plugins: empty', async (t) => {
|
||||
const plugins = [];
|
||||
const options = {
|
||||
plugins,
|
||||
};
|
||||
|
||||
const {body} = await request.get('/plugins.js', {
|
||||
options,
|
||||
});
|
||||
|
||||
t.equal(body, '', 'should content be empty');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: plugins: one', async (t) => {
|
||||
const plugins = [
|
||||
__filename,
|
||||
];
|
||||
|
||||
const options = {
|
||||
plugins,
|
||||
};
|
||||
|
||||
const {body} = await request.get('/plugins.js', {
|
||||
options,
|
||||
});
|
||||
|
||||
const file = fs.readFileSync(__filename, 'utf8');
|
||||
|
||||
t.equal(body, file, 'should return file plugin content');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: plugins: load error', async (t) => {
|
||||
const noEntry = __filename + Math.random();
|
||||
const plugins = [
|
||||
__filename,
|
||||
noEntry,
|
||||
];
|
||||
|
||||
const msg = `ENOENT: no such file or directory, open '${noEntry}'`;
|
||||
|
||||
const options = {
|
||||
plugins,
|
||||
};
|
||||
|
||||
const {body} = await request.get('/plugins.js', {
|
||||
options,
|
||||
});
|
||||
|
||||
const file = fs.readFileSync(__filename, 'utf8') + msg;
|
||||
|
||||
t.equal(body, file, 'should return file plugin content');
|
||||
t.end();
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue