@@ -744,4 +744,75 @@ describe('schemas', () => {
744
744
done ( ) ;
745
745
} ) ;
746
746
} ) ;
747
+
748
+ it ( 'deletes schema when actual collection does not exist' , done => {
749
+ request . post ( {
750
+ url : 'http://localhost:8378/1/schemas/NewClassForDelete' ,
751
+ headers : masterKeyHeaders ,
752
+ json : true ,
753
+ body : {
754
+ className : 'NewClassForDelete'
755
+ }
756
+ } , ( error , response , body ) => {
757
+ expect ( error ) . toEqual ( null ) ;
758
+ expect ( response . body . className ) . toEqual ( 'NewClassForDelete' ) ;
759
+ request . del ( {
760
+ url : 'http://localhost:8378/1/schemas/NewClassForDelete' ,
761
+ headers : masterKeyHeaders ,
762
+ json : true ,
763
+ } , ( error , response , body ) => {
764
+ expect ( response . statusCode ) . toEqual ( 200 ) ;
765
+ expect ( response . body ) . toEqual ( { } ) ;
766
+ config . database . loadSchema ( ) . then ( schema => {
767
+ schema . hasClass ( 'NewClassForDelete' ) . then ( exist => {
768
+ expect ( exist ) . toEqual ( false ) ;
769
+ done ( ) ;
770
+ } ) ;
771
+ } )
772
+ } ) ;
773
+ } ) ;
774
+ } ) ;
775
+
776
+ it ( 'deletes schema when actual collection exists' , done => {
777
+ request . post ( {
778
+ url : 'http://localhost:8378/1/schemas/NewClassForDelete' ,
779
+ headers : masterKeyHeaders ,
780
+ json : true ,
781
+ body : {
782
+ className : 'NewClassForDelete'
783
+ }
784
+ } , ( error , response , body ) => {
785
+ expect ( error ) . toEqual ( null ) ;
786
+ expect ( response . body . className ) . toEqual ( 'NewClassForDelete' ) ;
787
+ request . post ( {
788
+ url : 'http://localhost:8378/1/classes/NewClassForDelete' ,
789
+ headers : restKeyHeaders ,
790
+ json : true
791
+ } , ( error , response , body ) => {
792
+ expect ( error ) . toEqual ( null ) ;
793
+ expect ( typeof response . body . objectId ) . toEqual ( 'string' ) ;
794
+ request . del ( {
795
+ url : 'http://localhost:8378/1/classes/NewClassForDelete/' + response . body . objectId ,
796
+ headers : restKeyHeaders ,
797
+ json : true ,
798
+ } , ( error , response , body ) => {
799
+ expect ( error ) . toEqual ( null ) ;
800
+ request . del ( {
801
+ url : 'http://localhost:8378/1/schemas/NewClassForDelete' ,
802
+ headers : masterKeyHeaders ,
803
+ json : true ,
804
+ } , ( error , response , body ) => {
805
+ expect ( response . statusCode ) . toEqual ( 200 ) ;
806
+ expect ( response . body ) . toEqual ( { } ) ;
807
+ config . database . loadSchema ( ) . then ( schema => {
808
+ schema . hasClass ( 'NewClassForDelete' ) . then ( exist => {
809
+ expect ( exist ) . toEqual ( false ) ;
810
+ done ( ) ;
811
+ } ) ;
812
+ } ) ;
813
+ } ) ;
814
+ } ) ;
815
+ } ) ;
816
+ } ) ;
817
+ } ) ;
747
818
} ) ;
0 commit comments