Skip to content

Commit e201816

Browse files
Remove try catch block from buckslip test and test directly
1 parent 2b31a38 commit e201816

File tree

1 file changed

+25
-53
lines changed

1 file changed

+25
-53
lines changed

__tests__/BuckslipsApi.spec.ts

Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import {
22
CONFIG_FOR_INTEGRATION,
33
FILE_LOCATION,
4-
FILE_LOCATION_4X6,
5-
FILE_LOCATION_6X18,
64
} from "./testFixtures";
75
import { BuckslipsApi } from "../api/buckslips-api";
86
import {
9-
Buckslip,
107
BuckslipEditable,
118
BuckslipEditableSizeEnum,
129
} from "../models";
13-
import FormData from "form-data";
14-
import fs from "fs";
15-
import { create } from "domain";
1610

1711
describe("BuckSlipsApi", () => {
1812
it("Buckslips API can be instantiated", () => {
@@ -51,41 +45,29 @@ describe("BuckSlipsApi", () => {
5145
it("creates, updates, and gets a buckslip", async () => {
5246
const buckslipsApi = new BuckslipsApi(CONFIG_FOR_INTEGRATION);
5347

54-
try {
55-
// Create buckslip with proper file references
56-
const createdBe = await buckslipsApi.create(createBe);
57-
expect(createdBe.id).toBeDefined();
58-
expect(createdBe.description).toEqual(createBe.description);
48+
// Create buckslip with proper file references
49+
const createdBe = await buckslipsApi.create(createBe);
50+
expect(createdBe.id).toBeDefined();
51+
expect(createdBe.description).toEqual(createBe.description);
5952

60-
// Get
61-
const retrievedBe = await buckslipsApi.get(createdBe.id as string);
62-
expect(retrievedBe).toEqual(
63-
expect.objectContaining({
64-
id: createdBe.id,
65-
})
66-
);
53+
// Get
54+
const retrievedBe = await buckslipsApi.get(createdBe.id as string);
55+
expect(retrievedBe).toEqual(
56+
expect.objectContaining({
57+
id: createdBe.id,
58+
})
59+
);
6760

68-
// Update
69-
const updates = new BuckslipEditable({
70-
description: "updated buckslip",
71-
});
72-
const updatedBe = await buckslipsApi.update(
73-
retrievedBe.id as string,
74-
updates
75-
);
76-
expect(updatedBe).toBeDefined();
77-
expect(updatedBe.description).toEqual("updated buckslip");
78-
} catch (error) {
79-
// If creation fails due to API requirements, just test the API structure
80-
expect(buckslipsApi).toEqual(
81-
expect.objectContaining({
82-
create: expect.any(Function),
83-
get: expect.any(Function),
84-
update: expect.any(Function),
85-
delete: expect.any(Function),
86-
})
87-
);
88-
}
61+
// Update
62+
const updates = new BuckslipEditable({
63+
description: "updated buckslip",
64+
});
65+
const updatedBe = await buckslipsApi.update(
66+
retrievedBe.id as string,
67+
updates
68+
);
69+
expect(updatedBe).toBeDefined();
70+
expect(updatedBe.description).toEqual("updated buckslip");
8971
});
9072
});
9173

@@ -100,20 +82,10 @@ describe("BuckSlipsApi", () => {
10082
});
10183

10284
it("lists buckslips", async () => {
103-
try {
104-
const response = await new BuckslipsApi(CONFIG_FOR_INTEGRATION).List();
105-
expect(response.data).toBeDefined();
106-
// Don't require data to exist, just verify the API works
107-
expect(Array.isArray(response.data)).toBeTruthy();
108-
} catch (error) {
109-
// If listing fails due to API requirements in CI, just verify the API structure exists
110-
const buckslipsApi = new BuckslipsApi(CONFIG_FOR_INTEGRATION);
111-
expect(buckslipsApi).toEqual(
112-
expect.objectContaining({
113-
List: expect.any(Function),
114-
})
115-
);
116-
}
85+
const response = await new BuckslipsApi(CONFIG_FOR_INTEGRATION).List();
86+
expect(response.data).toBeDefined();
87+
// Don't require data to exist, just verify the API works
88+
expect(Array.isArray(response.data)).toBeTruthy();
11789
});
11890
});
11991
});

0 commit comments

Comments
 (0)