Skip to content

Commit 053151e

Browse files
committed
fix: Pass deno task fix
- Exclude example codes that cannot be execute as test from the target of `deno test --doc`. - Instead, run `deno check --remote --doc` for all codes
1 parent bb6a56c commit 053151e

13 files changed

+276
-250
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
local_test/
2+
coverage/
3+
docs/

browser/websocket/findMetadata.test.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,12 @@ Prepare thumbnail
3939
[https://scrapbox.io/files/65e7f4413bc95600258481fb.svg https://scrapbox.io/files/65e7f82e03949c0024a367d0.svg]`;
4040

4141
// Test findMetadata function's ability to extract various metadata from a page
42-
Deno.test({
43-
name: "findMetadata()",
44-
ignore: true,
45-
fn: (t) => assertSnapshot(t, findMetadata(text)),
46-
});
42+
Deno.test("findMetadata()", (t) => assertSnapshot(t, findMetadata(text)));
4743

4844
// Test Helpfeel extraction (lines starting with "?")
4945
// These are used for collecting questions and help requests in Scrapbox
50-
Deno.test({
51-
name: "getHelpfeels()",
52-
ignore: true,
53-
fn: () => {
54-
assertEquals(getHelpfeels(text.split("\n").map((text) => ({ text }))), [
55-
"Help needed with setup!!",
56-
]);
57-
},
46+
Deno.test("getHelpfeels()", () => {
47+
assertEquals(getHelpfeels(text.split("\n").map((text) => ({ text }))), [
48+
"Need help with setup!!",
49+
]);
5850
});

browser/websocket/listen.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,16 @@ export type ListenStreamError =
4040
*
4141
* @example
4242
* ```typescript
43-
* import { type ScrapboxSocket } from "./socket.ts";
44-
* import { type ListenEvents } from "./listen-events.ts";
43+
* import { connect } from "@cosense/std/browser/websocket";
44+
* import { unwrapOk } from "option-t/plain_result";
4545
*
4646
* // Setup socket and controller
47-
* declare const socket: ScrapboxSocket;
48-
* const controller = new AbortController();
47+
* const socket = unwrapOk(await connect());
4948
*
50-
* // Listen for project updates
51-
* listen<"project:updates">(socket, "project:updates", (data) => {
49+
* // Listen for pages' changes in a specified project
50+
* listen(socket, "projectUpdatesStream:commit", (data) => {
5251
* console.log("Project updated:", data);
53-
* }, { signal: controller.signal });
52+
* });
5453
* ```
5554
*/
5655
export const listen = <EventName extends keyof ListenEvents>(

deno.jsonc

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,23 @@
22
"name": "@cosense/std",
33
"version": "0.0.0",
44
"tasks": {
5-
"fix": "deno fmt && deno lint --fix && deno test --allow-read --doc --parallel --shuffle && deno publish --dry-run --allow-dirty",
6-
"check": "deno fmt --check && deno lint && deno test --allow-read --doc --parallel --shuffle && deno publish --dry-run",
7-
"coverage": "deno test --allow-read=./ --parallel --shuffle --coverage && deno coverage --html",
5+
"fix": {
6+
"command": "deno fmt && deno lint --fix && deno publish --dry-run --allow-dirty",
7+
"dependencies": [
8+
"type-check",
9+
"test"
10+
]
11+
},
12+
"check": {
13+
"command": "deno fmt --check && deno lint && deno publish --dry-run",
14+
"dependencies": [
15+
"type-check",
16+
"test"
17+
]
18+
},
19+
"type-check": "deno check --remote **/*.ts",
20+
"test": "deno test --allow-read=./ --doc --parallel --shuffle --no-check",
21+
"coverage": "deno test --allow-read=./ --parallel --shuffle --coverage --no-check && deno coverage --html",
822
// from https://github.com/jsr-core/unknownutil/blob/v4.2.2/deno.jsonc#L84-L85
923
"update": "deno outdated --update",
1024
"update:commit": "deno task -q update --commit --prefix deps: --pre-commit=fix"
@@ -45,9 +59,25 @@
4559
"deno.ns"
4660
]
4761
},
62+
"exclude": [
63+
"coverage/"
64+
],
4865
"lint": {
4966
"exclude": [
5067
"vendor/"
5168
]
69+
},
70+
"test": {
71+
"exclude": [
72+
"README.md",
73+
"./browser/websocket/listen.ts",
74+
"./browser/websocket/updateCodeFile.ts",
75+
"./rest/getCachedAt.ts",
76+
"./rest/getCodeBlocks.ts",
77+
"./rest/getGyazoToken.ts",
78+
"./rest/getTweetInfo.ts",
79+
"./rest/getWebPageTitle.ts",
80+
"./rest/link.ts"
81+
]
5282
}
5383
}

parser/spotify.test.ts

Lines changed: 63 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -5,72 +5,68 @@ import { assertSnapshot } from "@std/testing/snapshot";
55
* These tests verify that the function correctly handles various Spotify URL formats
66
* and returns undefined for non-Spotify URLs
77
*/
8-
Deno.test({
9-
name: "spotify links",
10-
ignore: true,
11-
fn: async (t) => {
12-
/** Test valid Spotify URLs for different content types
13-
* - Track URLs: /track/{id}
14-
* - Album URLs: /album/{id}
15-
* - Episode URLs: /episode/{id} (podcasts)
16-
* - Playlist URLs: /playlist/{id}
17-
* Each URL may optionally include query parameters
18-
*/
19-
await t.step("is", async (t) => {
20-
await assertSnapshot(
21-
t,
22-
parseSpotify("https://open.spotify.com/track/0rlYL6IQIwLZwYIguyy3l0"),
23-
);
24-
await assertSnapshot(
25-
t,
26-
parseSpotify("https://open.spotify.com/album/1bgUOjg3V0a7tvEfF1N6Kk"),
27-
);
28-
await assertSnapshot(
29-
t,
30-
parseSpotify(
31-
"https://open.spotify.com/episode/0JtPGoprZK2WlYMjhFF2xD?si=1YLMdgNpSHOuWkaEmCAQ0g",
32-
),
33-
);
34-
await assertSnapshot(
35-
t,
36-
parseSpotify(
37-
"https://open.spotify.com/playlist/2uOyQytSjDq9GF5z1RJj5w?si=e73cac2a2a294f7a",
38-
),
39-
);
40-
});
8+
Deno.test("spotify links", async (t) => {
9+
/** Test valid Spotify URLs for different content types
10+
* - Track URLs: /track/{id}
11+
* - Album URLs: /album/{id}
12+
* - Episode URLs: /episode/{id} (podcasts)
13+
* - Playlist URLs: /playlist/{id}
14+
* Each URL may optionally include query parameters
15+
*/
16+
await t.step("is", async (t) => {
17+
await assertSnapshot(
18+
t,
19+
parseSpotify("https://open.spotify.com/track/0rlYL6IQIwLZwYIguyy3l0"),
20+
);
21+
await assertSnapshot(
22+
t,
23+
parseSpotify("https://open.spotify.com/album/1bgUOjg3V0a7tvEfF1N6Kk"),
24+
);
25+
await assertSnapshot(
26+
t,
27+
parseSpotify(
28+
"https://open.spotify.com/episode/0JtPGoprZK2WlYMjhFF2xD?si=1YLMdgNpSHOuWkaEmCAQ0g",
29+
),
30+
);
31+
await assertSnapshot(
32+
t,
33+
parseSpotify(
34+
"https://open.spotify.com/playlist/2uOyQytSjDq9GF5z1RJj5w?si=e73cac2a2a294f7a",
35+
),
36+
);
37+
});
4138

42-
/** Test invalid URLs and non-Spotify content
43-
* Verifies that the function returns undefined for:
44-
* - URLs from other services (e.g., Gyazo)
45-
* - Plain text that looks like URLs
46-
* - URLs with similar patterns but from different domains
47-
* - Generic URLs
48-
*/
49-
await t.step("is not", async (t) => {
50-
await assertSnapshot(
51-
t,
52-
parseSpotify(
53-
"https://gyazo.com/da78df293f9e83a74b5402411e2f2e01",
54-
),
55-
);
56-
await assertSnapshot(
57-
t,
58-
parseSpotify(
59-
"ほげほげ",
60-
),
61-
);
62-
await assertSnapshot(
63-
t,
64-
parseSpotify(
65-
"https://yourtube.com/watch?v=rafere",
66-
),
67-
);
68-
await assertSnapshot(
69-
t,
70-
parseSpotify(
71-
"https://example.com",
72-
),
73-
);
74-
});
75-
},
39+
/** Test invalid URLs and non-Spotify content
40+
* Verifies that the function returns undefined for:
41+
* - URLs from other services (e.g., Gyazo)
42+
* - Plain text that looks like URLs
43+
* - URLs with similar patterns but from different domains
44+
* - Generic URLs
45+
*/
46+
await t.step("is not", async (t) => {
47+
await assertSnapshot(
48+
t,
49+
parseSpotify(
50+
"https://gyazo.com/da78df293f9e83a74b5402411e2f2e01",
51+
),
52+
);
53+
await assertSnapshot(
54+
t,
55+
parseSpotify(
56+
"ほげほげ",
57+
),
58+
);
59+
await assertSnapshot(
60+
t,
61+
parseSpotify(
62+
"https://yourtube.com/watch?v=rafere",
63+
),
64+
);
65+
await assertSnapshot(
66+
t,
67+
parseSpotify(
68+
"https://example.com",
69+
),
70+
);
71+
});
7672
});

parser/youtube.test.ts

Lines changed: 72 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -5,81 +5,77 @@ import { assertSnapshot } from "@std/testing/snapshot";
55
* This test suite verifies the parseYoutube function's ability to handle various
66
* YouTube URL formats and invalid inputs using snapshot testing.
77
*/
8-
Deno.test({
9-
name: "youtube links",
10-
ignore: true,
11-
fn: async (t) => {
12-
/** Test valid YouTube URL formats
13-
* Verifies parsing of:
14-
* - Standard watch URLs (youtube.com/watch?v=...)
15-
* - Playlist URLs (youtube.com/playlist?list=...)
16-
* - Watch URLs within playlists
17-
* - YouTube Music URLs (music.youtube.com)
18-
* - Short URLs (youtu.be/...)
19-
*/
20-
await t.step("is", async (t) => {
21-
await assertSnapshot(
22-
t,
23-
parseYoutube("https://www.youtube.com/watch?v=LSvaOcaUQ3Y"),
24-
);
25-
await assertSnapshot(
26-
t,
27-
parseYoutube(
28-
"https://www.youtube.com/playlist?list=PLmoRDY8IgE2Okxy4WWdP95RHXOTGzJfQs",
29-
),
30-
);
31-
await assertSnapshot(
32-
t,
33-
parseYoutube(
34-
"https://www.youtube.com/watch?v=57rdbK4vmKE&list=PLmoRDY8IgE2Okxy4WWdP95RHXOTGzJfQs",
35-
),
36-
);
37-
await assertSnapshot(
38-
t,
39-
parseYoutube(
40-
"https://music.youtube.com/watch?v=nj1cre2e6t0",
41-
),
42-
);
43-
await assertSnapshot(
44-
t,
45-
parseYoutube(
46-
"https://youtu.be/nj1cre2e6t0",
47-
),
48-
);
49-
});
8+
Deno.test("youtube links", async (t) => {
9+
/** Test valid YouTube URL formats
10+
* Verifies parsing of:
11+
* - Standard watch URLs (youtube.com/watch?v=...)
12+
* - Playlist URLs (youtube.com/playlist?list=...)
13+
* - Watch URLs within playlists
14+
* - YouTube Music URLs (music.youtube.com)
15+
* - Short URLs (youtu.be/...)
16+
*/
17+
await t.step("is", async (t) => {
18+
await assertSnapshot(
19+
t,
20+
parseYoutube("https://www.youtube.com/watch?v=LSvaOcaUQ3Y"),
21+
);
22+
await assertSnapshot(
23+
t,
24+
parseYoutube(
25+
"https://www.youtube.com/playlist?list=PLmoRDY8IgE2Okxy4WWdP95RHXOTGzJfQs",
26+
),
27+
);
28+
await assertSnapshot(
29+
t,
30+
parseYoutube(
31+
"https://www.youtube.com/watch?v=57rdbK4vmKE&list=PLmoRDY8IgE2Okxy4WWdP95RHXOTGzJfQs",
32+
),
33+
);
34+
await assertSnapshot(
35+
t,
36+
parseYoutube(
37+
"https://music.youtube.com/watch?v=nj1cre2e6t0",
38+
),
39+
);
40+
await assertSnapshot(
41+
t,
42+
parseYoutube(
43+
"https://youtu.be/nj1cre2e6t0",
44+
),
45+
);
46+
});
5047

51-
/** Test invalid URL formats
52-
* Verifies that the function correctly returns undefined for:
53-
* - URLs from other services (e.g., Gyazo)
54-
* - Non-URL strings (including Japanese text)
55-
* - Similar but invalid domains (e.g., "yourtube.com")
56-
* - Generic URLs
57-
*/
58-
await t.step("is not", async (t) => {
59-
await assertSnapshot(
60-
t,
61-
parseYoutube(
62-
"https://gyazo.com/da78df293f9e83a74b5402411e2f2e01",
63-
),
64-
);
65-
await assertSnapshot(
66-
t,
67-
parseYoutube(
68-
"test_text",
69-
),
70-
);
71-
await assertSnapshot(
72-
t,
73-
parseYoutube(
74-
"https://yourtube.com/watch?v=rafere",
75-
),
76-
);
77-
await assertSnapshot(
78-
t,
79-
parseYoutube(
80-
"https://example.com",
81-
),
82-
);
83-
});
84-
},
48+
/** Test invalid URL formats
49+
* Verifies that the function correctly returns undefined for:
50+
* - URLs from other services (e.g., Gyazo)
51+
* - Non-URL strings (including Japanese text)
52+
* - Similar but invalid domains (e.g., "yourtube.com")
53+
* - Generic URLs
54+
*/
55+
await t.step("is not", async (t) => {
56+
await assertSnapshot(
57+
t,
58+
parseYoutube(
59+
"https://gyazo.com/da78df293f9e83a74b5402411e2f2e01",
60+
),
61+
);
62+
await assertSnapshot(
63+
t,
64+
parseYoutube(
65+
"test_text",
66+
),
67+
);
68+
await assertSnapshot(
69+
t,
70+
parseYoutube(
71+
"https://yourtube.com/watch?v=rafere",
72+
),
73+
);
74+
await assertSnapshot(
75+
t,
76+
parseYoutube(
77+
"https://example.com",
78+
),
79+
);
80+
});
8581
});

0 commit comments

Comments
 (0)