|
| 1 | +import { test } from '@jest/globals'; |
| 2 | +import { |
| 3 | + GetBillingAccountCommand, |
| 4 | + LinkBillingAccountCommand, |
| 5 | + UpdateBillingAccountCommand, |
| 6 | +} from './fixtures/test1/commands.js'; |
| 7 | +import { BillingServiceRestApiRestClient } from './fixtures/test1/main.js'; |
| 8 | +import { BillingCountry, type BillingAccount } from './fixtures/test1/types.js'; |
| 9 | + |
| 10 | +const test1Client = new BillingServiceRestApiRestClient( |
| 11 | + new URL('http://invalid'), |
| 12 | +); |
| 13 | + |
| 14 | +test('command that will result in a void response', async () => { |
| 15 | + const command = new LinkBillingAccountCommand({ |
| 16 | + accountId: '1234', |
| 17 | + billingAccountId: '5678', |
| 18 | + }); |
| 19 | + |
| 20 | + try { |
| 21 | + const res = await test1Client.json(command); |
| 22 | + |
| 23 | + // @ts-expect-error |
| 24 | + const typeTest: void = res; |
| 25 | + } catch (err) { |
| 26 | + console.log(Object(err).message); |
| 27 | + } |
| 28 | +}); |
| 29 | + |
| 30 | +test('command without a body', async () => { |
| 31 | + const command = new GetBillingAccountCommand({ |
| 32 | + billingAccountId: '5678', |
| 33 | + }); |
| 34 | + |
| 35 | + try { |
| 36 | + const res: BillingAccount = await test1Client.json(command); |
| 37 | + |
| 38 | + const billingAccountId: string = res.billingAccountId; |
| 39 | + } catch (err) { |
| 40 | + console.log(Object(err).message); |
| 41 | + } |
| 42 | +}); |
| 43 | + |
| 44 | +test('command with a body', async () => { |
| 45 | + const command = new UpdateBillingAccountCommand({ |
| 46 | + billingAccountId: '5678', |
| 47 | + country: BillingCountry.Sg, |
| 48 | + }); |
| 49 | + |
| 50 | + try { |
| 51 | + const res = await test1Client.json(command); |
| 52 | + // @ts-expect-error |
| 53 | + const billingAccountId: string = res.billingAccountId; |
| 54 | + } catch (err) { |
| 55 | + console.log(Object(err).message); |
| 56 | + } |
| 57 | +}); |
0 commit comments