File tree Expand file tree Collapse file tree 3 files changed +58
-5
lines changed
Expand file tree Collapse file tree 3 files changed +58
-5
lines changed Original file line number Diff line number Diff line change 11import { FS } from '#common/cloudfunc' ;
22import { sendRequest as _sendRequest } from './send-request.mjs' ;
33
4+ const { assign} = Object ;
5+
46const 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
1932export const patch = async ( url , data ) => {
Original file line number Diff line number Diff 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+ } ) ;
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments