@@ -121,9 +121,77 @@ describe('#DoorKeeper #package', () => {
121121 } ) ;
122122 it ( `Should resolve a correct JSON object when try to validate a schema that is in the scope and is CORRECT` , async ( ) => {
123123 await expect ( dk . validate ( 'Config.Artifact' , artifact , v4 ( ) ) ) . resolves . toBe ( artifact ) ;
124+ await expect ( dk . validate ( 'Config.Artifact' , artifact ) ) . resolves . toBe ( artifact ) ;
125+ } ) ;
126+ it ( `Should invoke the callback a correct JSON object when try to validate a schema that is in the scope and is CORRECT` , done => {
127+ dk . validate ( 'Config.Artifact' , artifact , ( error , result ) => {
128+ expect ( error ) . toBeUndefined ( ) ;
129+ expect ( result ) . toEqual ( artifact ) ;
130+ done ( ) ;
131+ } ) ;
132+ } ) ;
133+ it ( `Should invoke the callback a correct JSON object when try to validate a schema that is in the scope and is CORRECT using external uuid` , done => {
134+ dk . validate ( 'Config.Artifact' , artifact , v4 ( ) , ( error , result ) => {
135+ expect ( error ) . toBeUndefined ( ) ;
136+ expect ( result ) . toEqual ( artifact ) ;
137+ done ( ) ;
138+ } ) ;
139+ } ) ;
140+ it ( `Should invoke the callback with an error when try to validate a schema that is in the scope and is INCORRECT` , done => {
141+ dk . validate ( 'Config.Artifact' , { } , ( error , result ) => {
142+ expect ( error ) . toBeInstanceOf ( Multi ) ;
143+ expect ( ( error as Multi ) . message ) . toEqual ( 'Errors during the schema validation process' ) ;
144+ expect ( ( error as Multi ) . name ) . toEqual ( 'ValidationError' ) ;
145+ expect ( ( error as Multi ) . causes ) . toBeDefined ( ) ;
146+ const causes = ( error as Multi ) . causes as Crash [ ] ;
147+ for ( const cause of causes ) {
148+ expect ( cause ) . toBeInstanceOf ( Crash ) ;
149+ expect ( cause . name ) . toEqual ( 'ValidationError' ) ;
150+ }
151+ const trace = ( error as Multi ) . trace ( ) ;
152+ expect ( trace ) . toEqual ( [
153+ "ValidationError: must have required property 'id'" ,
154+ "ValidationError: must have required property 'processId'" ,
155+ "ValidationError: must have required property 'release'" ,
156+ "ValidationError: must have required property 'version'" ,
157+ ] ) ;
158+ expect ( result ) . toEqual ( { } ) ;
159+ done ( ) ;
160+ } ) ;
161+ } ) ;
162+ it ( `Should invoke the callback with an error when try to validate a schema that is in the scope and is INCORRECT using external uuid` , done => {
163+ dk . validate ( 'Config.Artifact' , { } , v4 ( ) , ( error , result ) => {
164+ expect ( error ) . toBeInstanceOf ( Multi ) ;
165+ expect ( ( error as Multi ) . message ) . toEqual ( 'Errors during the schema validation process' ) ;
166+ expect ( ( error as Multi ) . name ) . toEqual ( 'ValidationError' ) ;
167+ expect ( ( error as Multi ) . causes ) . toBeDefined ( ) ;
168+ const causes = ( error as Multi ) . causes as Crash [ ] ;
169+ for ( const cause of causes ) {
170+ expect ( cause ) . toBeInstanceOf ( Crash ) ;
171+ expect ( cause . name ) . toEqual ( 'ValidationError' ) ;
172+ }
173+ const trace = ( error as Multi ) . trace ( ) ;
174+ expect ( trace ) . toEqual ( [
175+ "ValidationError: must have required property 'id'" ,
176+ "ValidationError: must have required property 'processId'" ,
177+ "ValidationError: must have required property 'release'" ,
178+ "ValidationError: must have required property 'version'" ,
179+ ] ) ;
180+ expect ( result ) . toEqual ( { } ) ;
181+ done ( ) ;
182+ } ) ;
124183 } ) ;
125184 it ( `Should resolve a correct JSON object when attempt to validate a schema that is in the scope and is CORRECT` , ( ) => {
126185 expect ( dk . attempt ( 'Config.Artifact' , artifact , v4 ( ) ) ) . toBe ( artifact ) ;
186+ expect ( dk . attempt ( 'Config.Artifact' , artifact ) ) . toBe ( artifact ) ;
187+ } ) ;
188+ it ( `Should return a TRUE value when try to check a schema that is in the scope and is CORRECT` , ( ) => {
189+ expect ( dk . check ( 'Config.Artifact' , artifact ) ) . toBeTruthy ( ) ;
190+ expect ( dk . check ( 'Config.Artifact' , artifact , v4 ( ) ) ) . toBeTruthy ( ) ;
191+ } ) ;
192+ it ( `Should return a FALSE value when try to check a schema that is in the scope and is INCORRECT` , ( ) => {
193+ expect ( dk . check ( 'Config.Artifact' , { } ) ) . toBeFalsy ( ) ;
194+ expect ( dk . check ( 'Config.Artifact' , { } , v4 ( ) ) ) . toBeFalsy ( ) ;
127195 } ) ;
128196 } ) ;
129197 describe ( '#Sad path' , ( ) => {
0 commit comments