Skip to content

Commit 10145dd

Browse files
author
murban
committed
update node versions we run ci against
Fix some linting issues that were making tests fail
1 parent bf3d416 commit 10145dd

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
node-version: [12.x, 14.x, 15.x]
8+
node-version: [16.x, 17.x, 18.x]
99
steps:
1010
- uses: actions/checkout@v3
1111
- name: Verify Node version ${{ matrix.node-version }}

src/apiUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const httpMethods = ["get", "post", "put", "delete", "options", "GET", "POST", "PUT", "DELETE", "OPTIONS"] as const;
2-
export type HTTPMethod = typeof httpMethods[number];
2+
export type HTTPMethod = (typeof httpMethods)[number];
33
export type ApiError = {
44
errors: string[];
55
ok: false;

test/ActionBatchHelpers.test.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { batchedApiRequest } from "../src/actionBatchHelpers";
2-
import { apiRequest } from "../src/apiUtils";
2+
import { ApiError, apiRequest } from "../src/apiUtils";
33

44
jest.mock("../src/apiUtils");
55
const mockedApiRequest = jest.mocked(apiRequest) as jest.Mock;
@@ -55,9 +55,9 @@ describe("ActionBatchHelpers", () => {
5555

5656
try {
5757
await batchedApiRequest(orgId, actions, authOptions);
58-
} catch (err: any) {
59-
expect(err.errors).not.toBeNull();
60-
expect(err.errors).toEqual(errorMsgs);
58+
} catch (err) {
59+
expect((err as ApiError).errors).not.toBeNull();
60+
expect((err as ApiError).errors).toEqual(errorMsgs);
6161
}
6262
});
6363

@@ -70,9 +70,9 @@ describe("ActionBatchHelpers", () => {
7070

7171
try {
7272
await batchedApiRequest(orgId, actions, authOptions);
73-
} catch (err: any) {
74-
expect(err.errors).not.toBeNull();
75-
expect(err.errors).toEqual(errorMsgs);
73+
} catch (err) {
74+
expect((err as ApiError).errors).not.toBeNull();
75+
expect((err as ApiError).errors).toEqual(errorMsgs);
7676
}
7777
});
7878

@@ -90,11 +90,14 @@ describe("ActionBatchHelpers", () => {
9090

9191
try {
9292
await batchedApiRequest(orgId, actions, authOptions, { maxPollingTime: 1 });
93-
} catch (err: any) {
94-
expect(err.errors).not.toBeNull();
95-
expect(err.errors).toEqual(["Your updates have been submitted and are still pending. Try reloading the page."]);
93+
} catch (err) {
94+
expect((err as ApiError).errors).not.toBeNull();
95+
expect((err as ApiError).errors).toEqual([
96+
"Your updates have been submitted and are still pending. Try reloading the page.",
97+
]);
9698
}
9799
});
100+
98101
it("polls the status when the initial status is pending", async () => {
99102
mockedApiRequest.mockResolvedValue({
100103
data: {
@@ -108,7 +111,7 @@ describe("ActionBatchHelpers", () => {
108111
});
109112
try {
110113
await batchedApiRequest(orgId, actions, authOptions, { maxPollingTime: 5 });
111-
} catch (err: unknown) {
114+
} catch (err) {
112115
expect(mockedApiRequest.mock.calls.length).toBeGreaterThan(1);
113116
expect(mockedApiRequest.mock.calls).toContainEqual(["GET", "/api/v1/organizations/2/actionBatches/1234"]);
114117
}
@@ -138,7 +141,7 @@ describe("ActionBatchHelpers", () => {
138141

139142
try {
140143
await batchedApiRequest(orgId, actions, authOptions, { maxPollingTime: 5 });
141-
} catch (err: unknown) {
144+
} catch (err) {
142145
expect(mockedApiRequest.mock.calls.length).toEqual(2); // one for the initial POST, and one status update
143146
expect(err).toMatchObject({ errors: ["some error"] });
144147
}

0 commit comments

Comments
 (0)