feature: client: dom: migrate to ESM

This commit is contained in:
coderiaser 2026-02-03 14:05:11 +02:00
parent 457c83dba9
commit bb32f7c448
3 changed files with 58 additions and 5 deletions

View file

@ -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) => {

View file

@ -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();
});

View file

@ -160,7 +160,7 @@
"@cloudcmd/stub": "^5.0.0",
"@iocmd/wait": "^2.1.0",
"@putout/eslint-flat": "^4.0.0",
"@putout/plugin-cloudcmd": "^5.0.0",
"@putout/plugin-cloudcmd": "^5.2.0",
"@types/node-fetch": "^2.6.11",
"auto-globals": "^4.0.0",
"babel-loader": "^10.0.0",