@@ -11,42 +11,39 @@ describe("isAfter", () => {
11
11
endDate ! : Date ;
12
12
}
13
13
14
- it ( "if endDate is after than startDate then it should succeed" , ( ) => {
14
+ it ( "if endDate is after than startDate then it should succeed" , async ( ) => {
15
15
const model = new MyClass ( ) ;
16
16
17
17
model . startDate = new Date ( "2022-02-21" ) ;
18
18
model . endDate = new Date ( "2022-05-01" ) ;
19
19
20
- return validator . validate ( model ) . then ( ( errors ) => {
21
- expect ( errors . length ) . toEqual ( 0 ) ;
22
- } ) ;
20
+ const errors = await validator . validate ( model ) ;
21
+ expect ( errors . length ) . toEqual ( 0 ) ;
23
22
} ) ;
24
23
25
- it ( "if endDate is not after than startDate then it should fail" , ( ) => {
24
+ it ( "if endDate is not after than startDate then it should fail" , async ( ) => {
26
25
const model = new MyClass ( ) ;
27
26
28
27
model . startDate = new Date ( "2022-02-21" ) ;
29
28
model . endDate = new Date ( "2022-01-01" ) ;
30
29
31
- return validator . validate ( model ) . then ( ( errors ) => {
32
- expect ( errors . length ) . toEqual ( 1 ) ;
33
- expect ( errors [ 0 ] . constraints ) . toEqual ( {
34
- IsAfterConstraint : "endDate should be after startDate" ,
35
- } ) ;
30
+ const errors = await validator . validate ( model ) ;
31
+ expect ( errors . length ) . toEqual ( 1 ) ;
32
+ expect ( errors [ 0 ] . constraints ) . toEqual ( {
33
+ IsAfterConstraint : "endDate should be after startDate" ,
36
34
} ) ;
37
35
} ) ;
38
36
39
- it ( "if endDate is equal to startDate then it should fail" , ( ) => {
37
+ it ( "if endDate is equal to startDate then it should fail" , async ( ) => {
40
38
const model = new MyClass ( ) ;
41
39
42
40
model . startDate = new Date ( "2022-02-21" ) ;
43
41
model . endDate = model . startDate ;
44
42
45
- return validator . validate ( model ) . then ( ( errors ) => {
46
- expect ( errors . length ) . toEqual ( 1 ) ;
47
- expect ( errors [ 0 ] . constraints ) . toEqual ( {
48
- IsAfterConstraint : "endDate should be after startDate" ,
49
- } ) ;
43
+ const errors = await validator . validate ( model ) ;
44
+ expect ( errors . length ) . toEqual ( 1 ) ;
45
+ expect ( errors [ 0 ] . constraints ) . toEqual ( {
46
+ IsAfterConstraint : "endDate should be after startDate" ,
50
47
} ) ;
51
48
} ) ;
52
49
} ) ;
0 commit comments