@@ -143,4 +143,58 @@ describe("invoices create", () => {
143143 pr_links : [ searchUrl , "https://github.com/org/repo/pull/42" ] ,
144144 } ) ;
145145 } ) ;
146+
147+ it ( "rejects invalid amount values before posting" , async ( ) => {
148+ const { handleError } = await import ( "../helpers.js" ) ;
149+
150+ await run ( [
151+ "invoices" , "create" , "gig-123" ,
152+ "--application-id" , "app-456" ,
153+ "--amount" , "not-a-number" ,
154+ "--payment-currency" , "usdc_pol" ,
155+ "--wallet-address" , "0xabc" ,
156+ ] ) ;
157+
158+ expect ( mockClient . post ) . not . toHaveBeenCalled ( ) ;
159+ expect ( handleError ) . toHaveBeenCalledWith (
160+ expect . objectContaining ( { message : expect . stringContaining ( "Invalid --amount" ) } ) ,
161+ expect . any ( Object )
162+ ) ;
163+ } ) ;
164+
165+ it ( "rejects partially numeric amount values before posting" , async ( ) => {
166+ const { handleError } = await import ( "../helpers.js" ) ;
167+
168+ await run ( [
169+ "invoices" , "create" , "gig-123" ,
170+ "--application-id" , "app-456" ,
171+ "--amount" , "10usd" ,
172+ "--payment-currency" , "usdc_pol" ,
173+ "--wallet-address" , "0xabc" ,
174+ ] ) ;
175+
176+ expect ( mockClient . post ) . not . toHaveBeenCalled ( ) ;
177+ expect ( handleError ) . toHaveBeenCalledWith (
178+ expect . objectContaining ( { message : expect . stringContaining ( "Invalid --amount" ) } ) ,
179+ expect . any ( Object )
180+ ) ;
181+ } ) ;
182+
183+ it ( "rejects non-positive line item quantities before posting" , async ( ) => {
184+ const { handleError } = await import ( "../helpers.js" ) ;
185+
186+ await run ( [
187+ "invoices" , "create" , "gig-123" ,
188+ "--application-id" , "app-456" ,
189+ "--item" , "Bug fix|-2|1" ,
190+ "--payment-currency" , "usdc_pol" ,
191+ "--wallet-address" , "0xabc" ,
192+ ] ) ;
193+
194+ expect ( mockClient . post ) . not . toHaveBeenCalled ( ) ;
195+ expect ( handleError ) . toHaveBeenCalledWith (
196+ expect . objectContaining ( { message : expect . stringContaining ( "positive quantity" ) } ) ,
197+ expect . any ( Object )
198+ ) ;
199+ } ) ;
146200} ) ;
0 commit comments