1
1
import { renderHook } from '@testing-library/react-hooks' ;
2
+ import { ReleaseCondition } from '../../types' ;
2
3
import { useReleaseStatus } from '../useReleaseStatus' ;
3
4
4
5
const mockRelease = {
@@ -19,46 +20,45 @@ describe('useApplicationSnapshots', () => {
19
20
expect ( result . current ) . toEqual ( 'Unknown' ) ;
20
21
} ) ;
21
22
22
- it ( 'should return in progress if any of the conditions is progressing' , ( ) => {
23
+ it ( 'should return in progress if release condition is progressing' , ( ) => {
23
24
const { result } = renderHook ( ( ) =>
24
25
useReleaseStatus ( {
25
26
...mockRelease ,
26
27
status : {
27
28
conditions : [
28
- { reason : 'Progressing' } ,
29
- { reason : 'Succeeded' , status : 'True' } ,
30
- { reason : 'Failed' , status : 'False' } ,
29
+ { reason : 'Succeeded' , status : 'True' , type : ReleaseCondition . Validated } ,
30
+ { reason : 'Progressing' , status : 'True' , type : ReleaseCondition . Released } ,
31
31
] ,
32
32
} ,
33
33
} ) ,
34
34
) ;
35
35
expect ( result . current ) . toEqual ( 'In Progress' ) ;
36
36
} ) ;
37
37
38
- it ( 'should return in succeeded if all of the conditions pass' , ( ) => {
38
+ it ( 'should return in succeeded if release condition pass' , ( ) => {
39
39
const { result } = renderHook ( ( ) =>
40
40
useReleaseStatus ( {
41
41
...mockRelease ,
42
42
status : {
43
43
conditions : [
44
- { reason : 'Succeeded' , status : 'True' } ,
45
- { reason : 'Succeeded ' , status : 'True' } ,
44
+ { reason : 'Succeeded' , status : 'True' , type : ReleaseCondition . Released } ,
45
+ { reason : 'Progressing ' , status : 'True' , type : ReleaseCondition . Validated } ,
46
46
] ,
47
47
} ,
48
48
} ) ,
49
49
) ;
50
50
expect ( result . current ) . toEqual ( 'Succeeded' ) ;
51
51
} ) ;
52
52
53
- it ( 'should return in failed if any of the conditions fail' , ( ) => {
53
+ it ( 'should return in failed if release condition is fail' , ( ) => {
54
54
const { result } = renderHook ( ( ) =>
55
55
useReleaseStatus ( {
56
56
...mockRelease ,
57
57
status : {
58
58
conditions : [
59
- { reason : 'Succeeded' , status : 'True' } ,
60
- { reason : 'Succeeded' , status : 'True' } ,
61
- { reason : 'Failed' , status : 'False' } ,
59
+ { reason : 'Succeeded' , status : 'True' , type : ReleaseCondition . Processed } ,
60
+ { reason : 'Succeeded' , status : 'True' , type : ReleaseCondition . Validated } ,
61
+ { reason : 'Failed' , status : 'False' , type : ReleaseCondition . Released } ,
62
62
] ,
63
63
} ,
64
64
} ) ,
0 commit comments