mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
81 lines
1.6 KiB
JavaScript
81 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
const {join} = require('path');
|
|
const {test, stub} = require('supertape');
|
|
|
|
const cloudcmdPath = join(__dirname, '..', '..');
|
|
const modulesPath = join(cloudcmdPath, 'json', 'modules.json');
|
|
|
|
const localModules = require(modulesPath);
|
|
const modulas = require(`${cloudcmdPath}/server/modulas`);
|
|
|
|
const cloudcmd = require(cloudcmdPath);
|
|
const {request} = require('serve-once')(cloudcmd, {
|
|
config: {
|
|
auth: false,
|
|
dropbox: false,
|
|
},
|
|
});
|
|
|
|
test('cloudcmd: modules', async (t) => {
|
|
const modules = {
|
|
data: {
|
|
FilePicker: {
|
|
key: 'hello',
|
|
},
|
|
},
|
|
};
|
|
|
|
const options = {
|
|
modules,
|
|
};
|
|
|
|
const expected = {
|
|
...localModules,
|
|
...modules,
|
|
};
|
|
|
|
const {body} = await request.get(`/json/modules.json`, {
|
|
type: 'json',
|
|
options,
|
|
});
|
|
|
|
t.deepEqual(body, expected);
|
|
t.end();
|
|
});
|
|
|
|
test('cloudcmd: modules: wrong route', async (t) => {
|
|
const modules = {
|
|
hello: 'world',
|
|
};
|
|
|
|
const options = {
|
|
modules,
|
|
};
|
|
|
|
const expected = {
|
|
...localModules,
|
|
...modules,
|
|
};
|
|
|
|
const {body} = await request.get(`/package.json`, {
|
|
type: 'json',
|
|
options,
|
|
});
|
|
|
|
t.notDeepEqual(body, expected, 'should not be equal');
|
|
t.end();
|
|
});
|
|
|
|
test('cloudcmd: modules: no', (t) => {
|
|
const fn = modulas();
|
|
const url = '/json/modules.json';
|
|
const send = stub();
|
|
|
|
fn({url}, {
|
|
send,
|
|
});
|
|
|
|
t.calledWith(send, [localModules], 'should have been called with modules');
|
|
t.end();
|
|
});
|