mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
test(config) coverage
This commit is contained in:
parent
ce794fe0be
commit
2abe7d688d
1 changed files with 5 additions and 19 deletions
|
|
@ -1,24 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
|
||||
const test = require('supertape');
|
||||
const readjson = require('readjson');
|
||||
const writejson = require('writejson');
|
||||
|
||||
const cloudcmd = require('../..');
|
||||
const configManager = cloudcmd.createConfigManager();
|
||||
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
config: {
|
||||
auth: false,
|
||||
},
|
||||
configManager: cloudcmd.createConfigManager(),
|
||||
configManager,
|
||||
});
|
||||
|
||||
const manageConfig = require('../../server/config');
|
||||
|
||||
const pathConfig = path.join(os.homedir(), '.cloudcmd.json');
|
||||
|
||||
test('cloudcmd: rest: config: get', async (t) => {
|
||||
const {body} = await request.get('/api/v1/config', {
|
||||
type: 'json',
|
||||
|
|
@ -93,7 +86,7 @@ test('cloudcmd: rest: config: patch: no configDialog: statusCode', async (t) =>
|
|||
options,
|
||||
});
|
||||
|
||||
manageConfig('configDialog', true);
|
||||
configManager('configDialog', true);
|
||||
|
||||
t.equal(response.status, 404);
|
||||
t.end();
|
||||
|
|
@ -104,18 +97,11 @@ test('cloudcmd: rest: config: patch: save config', async (t) => {
|
|||
editor: 'dword',
|
||||
};
|
||||
|
||||
const originalConfig = readjson.sync.try(pathConfig);
|
||||
|
||||
await request.patch(`/api/v1/config`, {
|
||||
body,
|
||||
});
|
||||
|
||||
const config = readjson.sync(pathConfig);
|
||||
|
||||
t.equal(config.editor, 'dword', 'should change config file on patch');
|
||||
t.equal(configManager('editor'), 'dword', 'should change config file on patch');
|
||||
t.end();
|
||||
|
||||
if (originalConfig)
|
||||
writejson.sync(pathConfig, originalConfig);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue