mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore: lint
This commit is contained in:
parent
98d3a4cc56
commit
95c36b0a37
15 changed files with 127 additions and 138 deletions
|
|
@ -8,7 +8,7 @@ const express = require('express');
|
|||
const io = require('socket.io');
|
||||
const writejson = require('writejson');
|
||||
const readjson = require('readjson');
|
||||
const {promisify} = require('util');
|
||||
const {promisify} = require('node:util');
|
||||
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
|
|
|
|||
|
|
@ -19,45 +19,45 @@ test('cloudcmd: rest: rename', async (t) => {
|
|||
'/fixture/mv.txt': 'hello',
|
||||
'/fixture/tmp/a.txt': 'a',
|
||||
};
|
||||
|
||||
|
||||
const vol = Volume.fromJSON(volume, '/');
|
||||
|
||||
|
||||
const unionFS = ufs
|
||||
.use(vol)
|
||||
.use(fs);
|
||||
|
||||
|
||||
mockRequire('node:fs', unionFS);
|
||||
|
||||
|
||||
reRequire('@cloudcmd/rename-files');
|
||||
reRequire('@cloudcmd/move-files');
|
||||
reRequire(restPath);
|
||||
|
||||
|
||||
const cloudcmd = reRequire(cloudcmdPath);
|
||||
const {createConfigManager} = cloudcmd;
|
||||
const configManager = createConfigManager();
|
||||
|
||||
|
||||
configManager('auth', false);
|
||||
configManager('root', '/');
|
||||
|
||||
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
configManager,
|
||||
});
|
||||
|
||||
|
||||
const files = {
|
||||
from: '/fixture/mv.txt',
|
||||
to: '/fixture/tmp/mv.txt',
|
||||
};
|
||||
|
||||
|
||||
const {body} = await request.put(`/api/v1/rename`, {
|
||||
body: files,
|
||||
});
|
||||
|
||||
|
||||
mockRequire.stopAll();
|
||||
|
||||
|
||||
const expected = 'rename: ok("{"from":"/fixture/mv.txt","to":"/fixture/tmp/mv.txt"}")';
|
||||
|
||||
|
||||
stopAll();
|
||||
|
||||
|
||||
t.equal(body, expected, 'should move');
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -65,23 +65,23 @@ test('cloudcmd: rest: rename', async (t) => {
|
|||
test('cloudcmd: rest: rename: no from', async (t) => {
|
||||
const cloudcmd = reRequire(cloudcmdPath);
|
||||
const {createConfigManager} = cloudcmd;
|
||||
|
||||
|
||||
const configManager = createConfigManager();
|
||||
configManager('auth', false);
|
||||
configManager('root', '/');
|
||||
|
||||
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
configManager,
|
||||
});
|
||||
|
||||
|
||||
const files = {};
|
||||
|
||||
|
||||
const {body} = await request.put(`/api/v1/rename`, {
|
||||
body: files,
|
||||
});
|
||||
|
||||
|
||||
const expected = '"from" should be filled';
|
||||
|
||||
|
||||
t.equal(body, expected);
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -89,25 +89,25 @@ test('cloudcmd: rest: rename: no from', async (t) => {
|
|||
test('cloudcmd: rest: rename: no to', async (t) => {
|
||||
const cloudcmd = reRequire(cloudcmdPath);
|
||||
const {createConfigManager} = cloudcmd;
|
||||
|
||||
|
||||
const configManager = createConfigManager();
|
||||
configManager('auth', false);
|
||||
configManager('root', '/');
|
||||
|
||||
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
configManager,
|
||||
});
|
||||
|
||||
|
||||
const files = {
|
||||
from: '/',
|
||||
};
|
||||
|
||||
|
||||
const {body} = await request.put(`/api/v1/rename`, {
|
||||
body: files,
|
||||
});
|
||||
|
||||
|
||||
const expected = '"to" should be filled';
|
||||
|
||||
|
||||
t.equal(body, expected);
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue