Skip to content

Commit

Permalink
chore: reduce to basic test for testing the codegen types, not the re…
Browse files Browse the repository at this point in the history
…st client
  • Loading branch information
maxholman committed May 11, 2023
1 parent 90aa8cc commit 257fe3b
Showing 1 changed file with 6 additions and 49 deletions.
55 changes: 6 additions & 49 deletions __tests__/test1.test.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,14 @@
import { test } from '@jest/globals';
import {
GetBillingAccountCommand,
LinkBillingAccountCommand,
UpdateBillingAccountCommand,
} from './fixtures/test1/commands.js';
import { GetBillingAccountCommand } from './fixtures/test1/commands.js';
import { BillingServiceRestApiRestClient } from './fixtures/test1/main.js';
import { BillingCountry, type BillingAccount } from './fixtures/test1/types.js';

const test1Client = new BillingServiceRestApiRestClient(
new URL('http://invalid'),
);

test('command that will result in a void response', async () => {
const command = new LinkBillingAccountCommand({
accountId: '1234',
billingAccountId: '5678',
});

try {
const res = await test1Client.json(command);

// @ts-expect-error
const typeTest: void = res;
} catch (err) {
console.log(Object(err).message);
}
});

test('command without a body', async () => {
test('Test1 GetBillingAccount', async () => {
const client = new BillingServiceRestApiRestClient(new URL('http://invalid'));
const command = new GetBillingAccountCommand({
billingAccountId: '5678',
billingAccountId: '1234',
});

try {
const res: BillingAccount = await test1Client.json(command);

const billingAccountId: string = res.billingAccountId;
} catch (err) {
console.log(Object(err).message);
}
});

test('command with a body', async () => {
const command = new UpdateBillingAccountCommand({
billingAccountId: '5678',
country: BillingCountry.Sg,
});
const result = await client.json(command).catch((err) => err);

try {
const res = await test1Client.json(command);
// @ts-expect-error
const billingAccountId: string = res.billingAccountId;
} catch (err) {
console.log(Object(err).message);
}
expect(result).toBeTruthy();
});

0 comments on commit 257fe3b

Please sign in to comment.