@@ -7,12 +7,23 @@ import {
7
7
import { afterEach , beforeEach , describe , expect , it } from 'vitest' ;
8
8
import { BillingService } from '../gen/app/v1/billing_connect' ;
9
9
import {
10
+ CreateInvoiceAndChargeImmediatelyRequest ,
11
+ CreateInvoiceAndChargeImmediatelyResponse ,
12
+ GetAvailableBillingTiersRequest ,
13
+ GetAvailableBillingTiersResponse ,
14
+ GetCurrentMonthUsageRequest ,
15
+ GetCurrentMonthUsageResponse ,
16
+ GetInvoicePdfRequest ,
10
17
GetInvoicePdfResponse ,
18
+ GetInvoicesSummaryRequest ,
11
19
GetInvoicesSummaryResponse ,
20
+ GetOrgBillingInformationRequest ,
12
21
PaymentMethodType ,
13
22
ResourceUsageCosts ,
14
23
ResourceUsageCostsBySource ,
24
+ SendPaymentRequiredEmailRequest ,
15
25
SourceType ,
26
+ UpdateOrganizationBillingTierRequest ,
16
27
UsageCost ,
17
28
UsageCostType ,
18
29
} from '../gen/app/v1/billing_pb' ;
@@ -162,4 +173,48 @@ describe('BillingClient tests', () => {
162
173
const array = new Uint8Array ( [ 1 , 2 , 3 , 4 ] ) ;
163
174
await expect ( promise ) . resolves . toStrictEqual ( array ) ;
164
175
} ) ;
165
- } ) ;
176
+
177
+ describe ( 'createInvoiceAndChargeImmediately tests' , ( ) => {
178
+ let capReq : CreateInvoiceAndChargeImmediatelyRequest ;
179
+ beforeEach ( ( ) => {
180
+ mockTransport = createRouterTransport ( ( { service } ) => {
181
+ service ( BillingService , {
182
+ createInvoiceAndChargeImmediately : ( req ) => {
183
+ capReq = req ;
184
+ return new CreateInvoiceAndChargeImmediatelyResponse ( ) ;
185
+ } ,
186
+ } ) ;
187
+ } ) ;
188
+ } ) ;
189
+
190
+ it ( 'creates and charges invoice immediately' , async ( ) => {
191
+ const expectedRequest = new CreateInvoiceAndChargeImmediatelyRequest ( {
192
+ orgIdToCharge : 'orgIdToCharge' ,
193
+ amount : 100.00 ,
194
+ description : 'test description' ,
195
+ orgIdForBranding : 'orgIdForBranding' ,
196
+ } ) ;
197
+
198
+ await subject ( ) . createInvoiceAndChargeImmediately (
199
+ 'orgIdToCharge' ,
200
+ 100.00 ,
201
+ 'test description' ,
202
+ 'orgIdForBranding'
203
+ ) ;
204
+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
205
+ } ) ;
206
+
207
+ it ( 'creates and charges invoice immediately with optional fields omitted' , async ( ) => {
208
+ const expectedRequest = new CreateInvoiceAndChargeImmediatelyRequest ( {
209
+ orgIdToCharge : 'orgIdToCharge' ,
210
+ amount : 100.00 ,
211
+ } ) ;
212
+
213
+ await subject ( ) . createInvoiceAndChargeImmediately (
214
+ 'orgIdToCharge' ,
215
+ 100.00
216
+ ) ;
217
+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
218
+ } ) ;
219
+ } ) ;
220
+ } ) ;
0 commit comments