@@ -611,3 +611,49 @@ describe('/policies', () => {
611
611
assert . equal ( stillExists , false , 'Policy is deleted' )
612
612
} )
613
613
} )
614
+ describe ( '/publications' , ( ) => {
615
+ const publication = {
616
+ name : 'a' ,
617
+ publish_insert : true ,
618
+ publish_update : true ,
619
+ publish_delete : true ,
620
+ publish_truncate : false ,
621
+ tables : [ 'users' ] ,
622
+ }
623
+ it ( 'POST' , async ( ) => {
624
+ const { data : newPublication } = await axios . post ( `${ URL } /publications` , publication )
625
+ assert . equal ( newPublication . name , publication . name )
626
+ assert . equal ( newPublication . publish_insert , publication . publish_insert )
627
+ assert . equal ( newPublication . publish_update , publication . publish_update )
628
+ assert . equal ( newPublication . publish_delete , publication . publish_delete )
629
+ assert . equal ( newPublication . publish_truncate , publication . publish_truncate )
630
+ assert . equal ( newPublication . tables . includes ( 'users' ) , true )
631
+ } )
632
+ it ( 'GET' , async ( ) => {
633
+ const res = await axios . get ( `${ URL } /publications` )
634
+ const newPublication = res . data [ 0 ]
635
+ assert . equal ( newPublication . name , publication . name )
636
+ } )
637
+ it ( 'PATCH' , async ( ) => {
638
+ const res = await axios . get ( `${ URL } /publications` )
639
+ const { id } = res . data [ 0 ]
640
+
641
+ const { data : updated } = await axios . patch ( `${ URL } /publications/${ id } ` , {
642
+ name : 'b' ,
643
+ publish_insert : false ,
644
+ tables : [ ] ,
645
+ } )
646
+ assert . equal ( updated . name , 'b' )
647
+ assert . equal ( updated . publish_insert , false )
648
+ assert . equal ( updated . tables . includes ( 'users' ) , false )
649
+ } )
650
+ it ( 'DELETE' , async ( ) => {
651
+ const res = await axios . get ( `${ URL } /publications` )
652
+ const { id } = res . data [ 0 ]
653
+
654
+ await axios . delete ( `${ URL } /publications/${ id } ` )
655
+ const { data : publications } = await axios . get ( `${ URL } /publications` )
656
+ const stillExists = publications . some ( ( x ) => x . id === id )
657
+ assert . equal ( stillExists , false )
658
+ } )
659
+ } )
0 commit comments