Skip to content

Commit 32926b2

Browse files
committed
chore: refactor test files
1 parent 67715b0 commit 32926b2

4 files changed

Lines changed: 72 additions & 14 deletions

File tree

__tests__/openai.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { test } from '@jest/globals';
2+
import { CreateModerationCommand } from './fixtures/openai/commands.js';
3+
import { OpenAiApiRestClient } from './fixtures/openai/main.js';
4+
5+
test('OpenAI CreateModeration', async () => {
6+
const openAiClient = new OpenAiApiRestClient(new URL('http://invalid'));
7+
8+
const command = new CreateModerationCommand({
9+
input: 'This is a test',
10+
});
11+
12+
const result = await openAiClient.json(command).catch((err) => err);
13+
14+
expect(result).toBeTruthy();
15+
});
Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { test } from '@jest/globals';
2-
import { CreateModerationCommand } from './fixtures/openai/commands.js';
3-
import { OpenAiApiRestClient } from './fixtures/openai/main.js';
42
import { FindPetsCommand } from './fixtures/petstore/commands.js';
53
import { SwaggerPetstoreRestClient } from './fixtures/petstore/main.js';
64

@@ -17,15 +15,3 @@ test('PetStore FindPets', async () => {
1715

1816
expect(result).toBeTruthy();
1917
});
20-
21-
test('OpenAI CreateModeration', async () => {
22-
const openAiClient = new OpenAiApiRestClient(new URL('http://invalid'));
23-
24-
const command = new CreateModerationCommand({
25-
input: 'This is a test',
26-
});
27-
28-
const result = await openAiClient.json(command).catch((err) => err);
29-
30-
expect(result).toBeTruthy();
31-
});

__tests__/test1.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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

Comments
 (0)