Skip to content

Commit 2e85948

Browse files
what am I doing?
1 parent f7915fb commit 2e85948

File tree

5 files changed

+570
-26
lines changed

5 files changed

+570
-26
lines changed

.github/workflows/deno.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Deno Format, Lint and Unit Tests
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
1010
test:
@@ -13,7 +13,10 @@ jobs:
1313
matrix:
1414
# we test on both most recent stable version of deno (v1.x) as well as
1515
# the version of deno used by Run on Slack (as noted in https://api.slack.com/slackcli/metadata.json)
16-
deno-version: [v1.x, v1.45.4]
16+
deno-version:
17+
- v1.x
18+
- v1.46.2
19+
- v2.x
1720
steps:
1821
- name: Setup repo
1922
uses: actions/checkout@v4
@@ -28,7 +31,7 @@ jobs:
2831
- name: Upload coverage to CodeCov
2932
uses: codecov/codecov-action@v5
3033
with:
31-
file: ./lcov.info
34+
files: ./lcov.info
3235
token: ${{ secrets.CODECOV_TOKEN }}
3336

3437
health-score:

scripts/src/import_map/update_test.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
import { isHttpError } from "@std/http/http-errors";
2-
import { mf } from "../../../src/dev_deps.ts";
32
import { assertEquals, assertRejects } from "@std/assert";
4-
import { afterEach, beforeAll } from "@std/testing/bdd";
53
import { apiDepsIn } from "./update.ts";
4+
import { stubFetch } from "../../../src/utils_test.ts";
65

76
const depsTsMock =
87
`export { SlackAPI } from "https://deno.land/x/deno_slack_api@2.1.0/mod.ts";
98
export type {SlackAPIClient, Trigger} from "https://deno.land/x/deno_slack_api@2.2.0/types.ts";`;
109

11-
beforeAll(() => {
12-
mf.install();
13-
});
14-
15-
afterEach(() => {
16-
mf.reset();
17-
});
18-
1910
Deno.test("apiDepsIn should return a list of the api module urls used by a module", async () => {
20-
mf.mock("GET@/x/deno_slack_sdk@x.x.x/deps.ts", (req: Request) => {
21-
assertEquals(
22-
req.url,
23-
"https://deno.land/x/deno_slack_sdk@x.x.x/deps.ts?source,file",
24-
);
25-
return new Response(depsTsMock);
11+
using _fetchStub = stubFetch(new Response(depsTsMock), {
12+
url: "https://deno.land/x/deno_slack_sdk@x.x.x/deps.ts?source,file",
2613
});
2714

2815
const apiDeps = await apiDepsIn(
@@ -39,8 +26,8 @@ Deno.test("apiDepsIn should return a list of the api module urls used by a modul
3926
});
4027

4128
Deno.test("apiDepsIn should throw http error on response not ok", async () => {
42-
mf.mock("GET@/x/deno_slack_sdk@x.x.x/deps.ts", () => {
43-
return new Response("error", { status: 500 });
29+
using _fetchStub = stubFetch(new Response("error", { status: 500 }), {
30+
url: "https://deno.land/x/deno_slack_sdk@x.x.x/deps.ts",
4431
});
4532

4633
const error = await assertRejects(() =>

src/api_test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "@std/assert";
88
import { SlackAPI } from "./mod.ts";
99
import { HttpError } from "@std/http/http-errors";
10+
import { stubFetch } from "./utils_test.ts";
1011

1112
Deno.test("SlackAPI class", async (t) => {
1213
mf.install(); // mock out calls to `fetch`
@@ -24,10 +25,14 @@ Deno.test("SlackAPI class", async (t) => {
2425

2526
await t.step("apiCall method", async (t) => {
2627
await t.step("should call the default API URL", async () => {
27-
mf.mock("POST@/api/chat.postMessage", (req: Request) => {
28-
assertEquals(req.url, "https://slack.com/api/chat.postMessage");
29-
assertExists(req.headers.has("user-agent"));
30-
return new Response('{"ok":true}');
28+
// mf.mock("POST@/api/chat.postMessage", (req: Request) => {
29+
// assertEquals(req.url, "https://slack.com/api/chat.postMessage");
30+
// assertExists(req.headers.has("user-agent"));
31+
// return new Response('{"ok":true}');
32+
// });
33+
using _fetchStub = stubFetch(new Response('{"ok":true}'), {
34+
url: "https://slack.com/api/chat.postMessage",
35+
init: { headers: { "user-agent": "hello" } },
3136
});
3237

3338
await client.apiCall("chat.postMessage", {});

0 commit comments

Comments
 (0)