File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ import Agent from "./Agent.js" ;
2
+
3
+ describe ( "Agent Model & schema" , ( ) => {
4
+ it ( "Deberia requerir un nombre y una edad valida" , async ( ) => {
5
+ let error ;
6
+ // Crear un agente incorrecto
7
+ const agent = new Agent ( {
8
+ name : "John Doe" ,
9
+ age : - 5 , // Edad inválida
10
+ } ) ;
11
+ try {
12
+ //Validarlo
13
+ await agent . validate ( ) ;
14
+ } catch ( er ) {
15
+ error = er ;
16
+ }
17
+ //Asegurarnos de que no pasa la validación
18
+ console . log ( error ) ;
19
+ expect ( error ) . toBeDefined ( ) ;
20
+ expect ( error . errors . age ) . toBeDefined ( ) ;
21
+ } ) ;
22
+
23
+ it ( "deberia aceptar una edad valida" , async ( ) => {
24
+ let error ;
25
+ // Crear un agente incorrecto
26
+ const agent = new Agent ( {
27
+ name : "John Two" ,
28
+ age : 19 , // Edad inválida
29
+ } ) ;
30
+ try {
31
+ //Validarlo
32
+ await agent . validate ( ) ;
33
+ } catch ( er ) {
34
+ error = er ;
35
+ }
36
+ //Asegurarnos de que no pasa la validación
37
+ //console.log(error);
38
+ expect ( error ) . not . toBeDefined ( ) ;
39
+ expect ( error ) . toBeUndefined ( ) ;
40
+ } ) ;
41
+ } ) ;
You can’t perform that action at this time.
0 commit comments