Skip to content

Commit bb32f7c

Browse files
committed
feature: client: dom: migrate to ESM
1 parent 457c83d commit bb32f7c

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

client/dom/io/index.mjs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
import {FS} from '#common/cloudfunc';
22
import {sendRequest as _sendRequest} from './send-request.mjs';
33

4+
const {assign} = Object;
5+
46
const imgPosition = {
57
top: true,
68
};
79

8-
export const remove = async (url, data) => {
9-
return await _sendRequest({
10+
export const remove = async (url, data, overrides = {}) => {
11+
const {
12+
sendRequest = _sendRequest,
13+
} = overrides;
14+
15+
const request = {
1016
method: 'DELETE',
1117
url: FS + url,
12-
data,
1318
imgPosition: {
1419
top: Boolean(data),
1520
},
16-
});
21+
};
22+
23+
if (data)
24+
assign(request, {
25+
data,
26+
url: `${request.url}?files`,
27+
});
28+
29+
return await sendRequest(request);
1730
};
1831

1932
export const patch = async (url, data) => {

client/dom/io/index.spec.mjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,43 @@ test('client: dom: io', (t) => {
1919
t.calledWith(sendRequest, [expected]);
2020
t.end();
2121
});
22+
23+
test('client: dom: io: remove: no files', async (t) => {
24+
const sendRequest = stub();
25+
26+
await io.remove('/hello', null, {
27+
sendRequest,
28+
});
29+
30+
const expected = {
31+
imgPosition: {
32+
top: false,
33+
},
34+
method: 'DELETE',
35+
url: '/fs/hello',
36+
};
37+
38+
t.calledWith(sendRequest, [expected]);
39+
t.end();
40+
});
41+
42+
test('client: dom: io: remove: files', async (t) => {
43+
const sendRequest = stub();
44+
const files = ['world'];
45+
46+
await io.remove('/hello', files, {
47+
sendRequest,
48+
});
49+
50+
const expected = {
51+
imgPosition: {
52+
top: true,
53+
},
54+
data: ['world'],
55+
method: 'DELETE',
56+
url: '/fs/hello?files',
57+
};
58+
59+
t.calledWith(sendRequest, [expected]);
60+
t.end();
61+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
"@cloudcmd/stub": "^5.0.0",
161161
"@iocmd/wait": "^2.1.0",
162162
"@putout/eslint-flat": "^4.0.0",
163-
"@putout/plugin-cloudcmd": "^5.0.0",
163+
"@putout/plugin-cloudcmd": "^5.2.0",
164164
"@types/node-fetch": "^2.6.11",
165165
"auto-globals": "^4.0.0",
166166
"babel-loader": "^10.0.0",

0 commit comments

Comments
 (0)