@@ -27,7 +27,7 @@ describe('defaultSchema', () => {
2727
2828 assetFailure (
2929 schema . validate ( { action : 'unknown' , params : { } } ) ,
30- '"action" must be one of [info, entriesByFolder, entriesByFiles, getEntry, persistEntry, getMedia, getMediaFile, persistMedia, deleteFile, deleteFiles, getDeployPreview]' ,
30+ '"action" must be one of [info, entriesByFolder, entriesByFiles, getEntry, unpublishedEntries, unpublishedEntry, unpublishedEntryDataFile, unpublishedEntryMediaFile, deleteUnpublishedEntry, persistEntry, updateUnpublishedEntryStatus, publishUnpublishedEntry , getMedia, getMediaFile, persistMedia, deleteFile, deleteFiles, getDeployPreview]' ,
3131 ) ;
3232 } ) ;
3333
@@ -134,6 +134,142 @@ describe('defaultSchema', () => {
134134 } ) ;
135135 } ) ;
136136
137+ describe ( 'unpublishedEntries' , ( ) => {
138+ it ( 'should fail on invalid params' , ( ) => {
139+ const schema = defaultSchema ( ) ;
140+
141+ assetFailure (
142+ schema . validate ( { action : 'unpublishedEntries' , params : { } } ) ,
143+ '"params.branch" is required' ,
144+ ) ;
145+ } ) ;
146+
147+ it ( 'should pass on valid params' , ( ) => {
148+ const schema = defaultSchema ( ) ;
149+ const { error } = schema . validate ( {
150+ action : 'unpublishedEntries' ,
151+ params : { ...defaultParams , branch : 'master' } ,
152+ } ) ;
153+
154+ expect ( error ) . toBeUndefined ( ) ;
155+ } ) ;
156+ } ) ;
157+
158+ describe ( 'unpublishedEntry' , ( ) => {
159+ it ( 'should fail on invalid params' , ( ) => {
160+ const schema = defaultSchema ( ) ;
161+ assetFailure (
162+ schema . validate ( { action : 'unpublishedEntry' , params : { } } ) ,
163+ '"params.branch" is required' ,
164+ ) ;
165+ } ) ;
166+
167+ it ( 'should pass on valid collection and slug' , ( ) => {
168+ const schema = defaultSchema ( ) ;
169+ const { error } = schema . validate ( {
170+ action : 'unpublishedEntry' ,
171+ params : { ...defaultParams , collection : 'collection' , slug : 'slug' } ,
172+ } ) ;
173+
174+ expect ( error ) . toBeUndefined ( ) ;
175+ } ) ;
176+
177+ it ( 'should pass on valid id' , ( ) => {
178+ const schema = defaultSchema ( ) ;
179+ const { error } = schema . validate ( {
180+ action : 'unpublishedEntry' ,
181+ params : { ...defaultParams , id : 'id' } ,
182+ } ) ;
183+
184+ expect ( error ) . toBeUndefined ( ) ;
185+ } ) ;
186+ } ) ;
187+
188+ [ 'unpublishedEntryDataFile' , 'unpublishedEntryMediaFile' ] . forEach ( action => {
189+ describe ( action , ( ) => {
190+ it ( 'should fail on invalid params' , ( ) => {
191+ const schema = defaultSchema ( ) ;
192+
193+ assetFailure (
194+ schema . validate ( { action, params : { ...defaultParams } } ) ,
195+ '"params.collection" is required' ,
196+ ) ;
197+ assetFailure (
198+ schema . validate ( {
199+ action,
200+ params : { ...defaultParams , collection : 'collection' } ,
201+ } ) ,
202+ '"params.slug" is required' ,
203+ ) ;
204+ assetFailure (
205+ schema . validate ( {
206+ action,
207+ params : { ...defaultParams , collection : 'collection' , slug : 'slug' } ,
208+ } ) ,
209+ '"params.id" is required' ,
210+ ) ;
211+ assetFailure (
212+ schema . validate ( {
213+ action,
214+ params : { ...defaultParams , collection : 'collection' , slug : 'slug' , id : 'id' } ,
215+ } ) ,
216+ '"params.path" is required' ,
217+ ) ;
218+ } ) ;
219+
220+ it ( 'should pass on valid params' , ( ) => {
221+ const schema = defaultSchema ( ) ;
222+ const { error } = schema . validate ( {
223+ action,
224+ params : {
225+ ...defaultParams ,
226+ collection : 'collection' ,
227+ slug : 'slug' ,
228+ id : 'id' ,
229+ path : 'path' ,
230+ } ,
231+ } ) ;
232+
233+ expect ( error ) . toBeUndefined ( ) ;
234+ } ) ;
235+ } ) ;
236+ } ) ;
237+
238+ describe ( 'deleteUnpublishedEntry' , ( ) => {
239+ it ( 'should fail on invalid params' , ( ) => {
240+ const schema = defaultSchema ( ) ;
241+
242+ assetFailure (
243+ schema . validate ( { action : 'deleteUnpublishedEntry' , params : { ...defaultParams } } ) ,
244+ '"params.collection" is required' ,
245+ ) ;
246+ assetFailure (
247+ schema . validate ( {
248+ action : 'deleteUnpublishedEntry' ,
249+ params : { ...defaultParams , collection : 'collection' } ,
250+ } ) ,
251+ '"params.slug" is required' ,
252+ ) ;
253+ assetFailure (
254+ schema . validate ( {
255+ action : 'deleteUnpublishedEntry' ,
256+ params : { ...defaultParams , collection : 'collection' , slug : 1 } ,
257+ } ) ,
258+ '"params.slug" must be a string' ,
259+ ) ;
260+ } ) ;
261+
262+ it ( 'should pass on valid params' , ( ) => {
263+ const schema = defaultSchema ( ) ;
264+ const { error } = schema . validate ( {
265+ action : 'deleteUnpublishedEntry' ,
266+ params : { ...defaultParams , collection : 'collection' , slug : 'slug' } ,
267+ } ) ;
268+
269+ expect ( error ) . toBeUndefined ( ) ;
270+ } ) ;
271+ } ) ;
272+
137273 describe ( 'persistEntry' , ( ) => {
138274 it ( 'should fail on invalid params' , ( ) => {
139275 const schema = defaultSchema ( ) ;
@@ -146,6 +282,8 @@ describe('defaultSchema', () => {
146282 assets : [ ] ,
147283 options : {
148284 commitMessage : 'commitMessage' ,
285+ useWorkflow : true ,
286+ status : 'draft' ,
149287 } ,
150288 } ,
151289 } ) ,
@@ -193,6 +331,8 @@ describe('defaultSchema', () => {
193331 assets : [ { path : 'path' , content : 'content' , encoding : 'base64' } ] ,
194332 options : {
195333 commitMessage : 'commitMessage' ,
334+ useWorkflow : true ,
335+ status : 'draft' ,
196336 } ,
197337 } ,
198338 } ) ;
@@ -210,6 +350,8 @@ describe('defaultSchema', () => {
210350 assets : [ { path : 'path' , content : 'content' , encoding : 'base64' } ] ,
211351 options : {
212352 commitMessage : 'commitMessage' ,
353+ useWorkflow : true ,
354+ status : 'draft' ,
213355 } ,
214356 } ,
215357 } ) ;
@@ -218,6 +360,69 @@ describe('defaultSchema', () => {
218360 } ) ;
219361 } ) ;
220362
363+ describe ( 'updateUnpublishedEntryStatus' , ( ) => {
364+ it ( 'should fail on invalid params' , ( ) => {
365+ const schema = defaultSchema ( ) ;
366+
367+ assetFailure (
368+ schema . validate ( { action : 'updateUnpublishedEntryStatus' , params : { ...defaultParams } } ) ,
369+ '"params.collection" is required' ,
370+ ) ;
371+ assetFailure (
372+ schema . validate ( {
373+ action : 'updateUnpublishedEntryStatus' ,
374+ params : { ...defaultParams , collection : 'collection' } ,
375+ } ) ,
376+ '"params.slug" is required' ,
377+ ) ;
378+ assetFailure (
379+ schema . validate ( {
380+ action : 'updateUnpublishedEntryStatus' ,
381+ params : { ...defaultParams , collection : 'collection' , slug : 'slug' } ,
382+ } ) ,
383+ '"params.newStatus" is required' ,
384+ ) ;
385+ } ) ;
386+
387+ it ( 'should pass on valid params' , ( ) => {
388+ const schema = defaultSchema ( ) ;
389+ const { error } = schema . validate ( {
390+ action : 'updateUnpublishedEntryStatus' ,
391+ params : { ...defaultParams , collection : 'collection' , slug : 'slug' , newStatus : 'draft' } ,
392+ } ) ;
393+
394+ expect ( error ) . toBeUndefined ( ) ;
395+ } ) ;
396+ } ) ;
397+
398+ describe ( 'publishUnpublishedEntry' , ( ) => {
399+ it ( 'should fail on invalid params' , ( ) => {
400+ const schema = defaultSchema ( ) ;
401+
402+ assetFailure (
403+ schema . validate ( { action : 'publishUnpublishedEntry' , params : { ...defaultParams } } ) ,
404+ '"params.collection" is required' ,
405+ ) ;
406+ assetFailure (
407+ schema . validate ( {
408+ action : 'publishUnpublishedEntry' ,
409+ params : { ...defaultParams , collection : 'collection' } ,
410+ } ) ,
411+ '"params.slug" is required' ,
412+ ) ;
413+ } ) ;
414+
415+ it ( 'should pass on valid params' , ( ) => {
416+ const schema = defaultSchema ( ) ;
417+ const { error } = schema . validate ( {
418+ action : 'publishUnpublishedEntry' ,
419+ params : { ...defaultParams , collection : 'collection' , slug : 'slug' } ,
420+ } ) ;
421+
422+ expect ( error ) . toBeUndefined ( ) ;
423+ } ) ;
424+ } ) ;
425+
221426 describe ( 'getMedia' , ( ) => {
222427 it ( 'should fail on invalid params' , ( ) => {
223428 const schema = defaultSchema ( ) ;
0 commit comments