mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature: client: dom: migrate to ESM
This commit is contained in:
parent
457c83dba9
commit
bb32f7c448
3 changed files with 58 additions and 5 deletions
|
|
@ -1,19 +1,32 @@
|
|||
import {FS} from '#common/cloudfunc';
|
||||
import {sendRequest as _sendRequest} from './send-request.mjs';
|
||||
|
||||
const {assign} = Object;
|
||||
|
||||
const imgPosition = {
|
||||
top: true,
|
||||
};
|
||||
|
||||
export const remove = async (url, data) => {
|
||||
return await _sendRequest({
|
||||
export const remove = async (url, data, overrides = {}) => {
|
||||
const {
|
||||
sendRequest = _sendRequest,
|
||||
} = overrides;
|
||||
|
||||
const request = {
|
||||
method: 'DELETE',
|
||||
url: FS + url,
|
||||
data,
|
||||
imgPosition: {
|
||||
top: Boolean(data),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
if (data)
|
||||
assign(request, {
|
||||
data,
|
||||
url: `${request.url}?files`,
|
||||
});
|
||||
|
||||
return await sendRequest(request);
|
||||
};
|
||||
|
||||
export const patch = async (url, data) => {
|
||||
|
|
|
|||
|
|
@ -19,3 +19,43 @@ test('client: dom: io', (t) => {
|
|||
t.calledWith(sendRequest, [expected]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('client: dom: io: remove: no files', async (t) => {
|
||||
const sendRequest = stub();
|
||||
|
||||
await io.remove('/hello', null, {
|
||||
sendRequest,
|
||||
});
|
||||
|
||||
const expected = {
|
||||
imgPosition: {
|
||||
top: false,
|
||||
},
|
||||
method: 'DELETE',
|
||||
url: '/fs/hello',
|
||||
};
|
||||
|
||||
t.calledWith(sendRequest, [expected]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('client: dom: io: remove: files', async (t) => {
|
||||
const sendRequest = stub();
|
||||
const files = ['world'];
|
||||
|
||||
await io.remove('/hello', files, {
|
||||
sendRequest,
|
||||
});
|
||||
|
||||
const expected = {
|
||||
imgPosition: {
|
||||
top: true,
|
||||
},
|
||||
data: ['world'],
|
||||
method: 'DELETE',
|
||||
url: '/fs/hello?files',
|
||||
};
|
||||
|
||||
t.calledWith(sendRequest, [expected]);
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue