@@ -30,41 +30,53 @@ describe('inputsHelper tests', () => {
3030 jest . resetModules ( )
3131 } )
3232
33- it ( 'requires token' , ( ) => {
34- assert . throws ( ( ) => {
35- inputsHelper . getInputs ( )
36- } , / t o k e n c a n ' t b e a n e m p t y s t r i n g / )
33+ it ( 'requires token' , async ( ) => {
34+ expect . assertions ( 1 )
35+ await expect ( inputsHelper . getInputs ( ) ) . rejects . toEqual (
36+ TypeError ( "token can't be an empty string" )
37+ )
3738 } )
3839
39- it ( 'requires name' , ( ) => {
40+ it ( 'requires name' , async ( ) => {
41+ expect . assertions ( 1 )
42+
4043 inputs . token = '1234567abcdefg'
41- assert . throws ( ( ) => {
42- inputsHelper . getInputs ( )
43- } , / n a m e c a n ' t b e a n e m p t y s t r i n g / )
44+
45+ await expect ( inputsHelper . getInputs ( ) ) . rejects . toEqual (
46+ TypeError ( "name can't be an empty string" )
47+ )
4448 } )
4549
46- it ( 'requires status' , ( ) => {
50+ it ( 'requires status' , async ( ) => {
51+ expect . assertions ( 1 )
52+
4753 inputs . name = 'my_name'
4854 inputs . token = '1234567abcdefg'
49- assert . throws ( ( ) => {
50- inputsHelper . getInputs ( )
51- } , / s t a t u s c a n ' t b e a n e m p t y s t r i n g / )
55+
56+ await expect ( inputsHelper . getInputs ( ) ) . rejects . toEqual (
57+ TypeError ( "status can't be an empty string" )
58+ )
5259 } )
5360
54- it ( 'requires valid commit status' , ( ) => {
61+ it ( 'requires valid commit status' , async ( ) => {
62+ expect . assertions ( 1 )
63+
5564 inputs . name = 'my_name'
5665 inputs . token = '1234567abcdefg'
5766 inputs . status = 'bleh'
58- assert . throws ( ( ) => {
59- inputsHelper . getInputs ( )
60- } , / T y p e E r r o r : u n k n o w n c o m m i t o r j o b s t a t u s : b l e h / )
67+
68+ await expect ( inputsHelper . getInputs ( ) ) . rejects . toEqual (
69+ TypeError ( 'unknown commit or job status: bleh' )
70+ )
6171 } )
6272
63- it ( 'sets correct default values' , ( ) => {
73+ it ( 'sets correct default values' , async ( ) => {
6474 inputs . name = 'my_name'
6575 inputs . token = '1234567abcdefg'
6676 inputs . status = 'Success'
67- const params : IParams = inputsHelper . getInputs ( )
77+
78+ const params : IParams = await inputsHelper . getInputs ( )
79+
6880 expect ( params ) . toBeTruthy ( )
6981 expect ( params . name ) . toBe ( 'my_name' )
7082 expect ( params . token ) . toBe ( '1234567abcdefg' )
@@ -79,7 +91,7 @@ describe('inputsHelper tests', () => {
7991 expect ( params . ignoreForks ) . toBeTruthy ( )
8092 } )
8193
82- it ( 'sets success status' , ( ) => {
94+ it ( 'sets success status' , async ( ) => {
8395 inputs . singleShot = 'false'
8496 inputs . status = 'Success'
8597 inputs . token = 'my_token'
@@ -92,7 +104,8 @@ describe('inputsHelper tests', () => {
92104 inputs . successComment = '/hold cancel'
93105 inputs . failComment = '/hold fail'
94106
95- const params : IParams = inputsHelper . getInputs ( )
107+ const params : IParams = await inputsHelper . getInputs ( )
108+
96109 expect ( params ) . toBeTruthy ( )
97110 expect ( params . token ) . toBe ( 'my_token' )
98111 expect ( params . url ) . toBe ( 'my_url' )
@@ -107,8 +120,7 @@ describe('inputsHelper tests', () => {
107120 expect ( params . ignoreForks ) . toBeTruthy ( )
108121 } )
109122
110- it ( 'sets pending status' , ( ) => {
111- const isPost = true
123+ it ( 'sets pending status' , async ( ) => {
112124 inputs . singleShot = 'false'
113125 inputs . status = 'Pending'
114126 inputs . token = 'my_token'
@@ -121,7 +133,8 @@ describe('inputsHelper tests', () => {
121133 inputs . successComment = '/hold cancel'
122134 inputs . failComment = '/hold fail'
123135
124- const params : IParams = inputsHelper . getInputs ( isPost )
136+ const params : IParams = await inputsHelper . getInputs ( )
137+
125138 expect ( params ) . toBeTruthy ( )
126139 expect ( params . token ) . toBe ( 'my_token' )
127140 expect ( params . url ) . toBe ( '' )
@@ -136,7 +149,7 @@ describe('inputsHelper tests', () => {
136149 expect ( params . ignoreForks ) . toBeFalsy ( )
137150 } )
138151
139- it ( 'sets correct status and comment' , ( ) => {
152+ it ( 'sets correct status and comment' , async ( ) => {
140153 inputs . singleShot = 'false'
141154 inputs . token = 'my_token'
142155 inputs . url = ''
@@ -149,31 +162,32 @@ describe('inputsHelper tests', () => {
149162 inputs . successComment = '/hold cancel'
150163 inputs . failComment = '/hold fail'
151164
152- let params : IParams = inputsHelper . getInputs ( )
165+ let params : IParams = await inputsHelper . getInputs ( )
166+
153167 expect ( params ) . toBeTruthy ( )
154168 expect ( params . status ) . toBe ( 'success' )
155169 expect ( params . selectedComment ) . toBe ( '/hold cancel' )
156170
157171 inputs . status = 'pending'
158- params = inputsHelper . getInputs ( )
172+ params = await inputsHelper . getInputs ( )
159173 expect ( params ) . toBeTruthy ( )
160174 expect ( params . status ) . toBe ( 'pending' )
161175 expect ( params . selectedComment ) . toBe ( '/hold' )
162176
163177 inputs . status = 'failure'
164- params = inputsHelper . getInputs ( )
178+ params = await inputsHelper . getInputs ( )
165179 expect ( params ) . toBeTruthy ( )
166180 expect ( params . status ) . toBe ( 'failure' )
167181 expect ( params . selectedComment ) . toBe ( '/hold fail' )
168182
169183 inputs . status = 'cancelled'
170- params = inputsHelper . getInputs ( )
184+ params = await inputsHelper . getInputs ( )
171185 expect ( params ) . toBeTruthy ( )
172186 expect ( params . status ) . toBe ( 'failure' )
173187 expect ( params . selectedComment ) . toBe ( '/hold fail' )
174188
175189 inputs . status = 'error'
176- params = inputsHelper . getInputs ( )
190+ params = await inputsHelper . getInputs ( )
177191 expect ( params ) . toBeTruthy ( )
178192 expect ( params . status ) . toBe ( 'error' )
179193 expect ( params . selectedComment ) . toBe ( '/hold fail' )
0 commit comments