Skip to content

Commit ea31889

Browse files
committed
.
1 parent 94bc65f commit ea31889

File tree

16 files changed

+110
-518
lines changed

16 files changed

+110
-518
lines changed

bun.lock

Lines changed: 36 additions & 448 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,16 @@
55
"private": true,
66
"repository": "github:platane/snk",
77
"devDependencies": {
8-
"@sucrase/jest-plugin": "3.0.0",
9-
"@types/jest": "29.5.12",
10-
"@types/node": "20.14.10",
11-
"jest": "29.7.0",
8+
"@types/bun": "1.2.2",
129
"prettier": "2.8.8",
13-
"sucrase": "3.35.0",
1410
"typescript": "5.5.3"
1511
},
1612
"workspaces": [
1713
"packages/*"
1814
],
19-
"jest": {
20-
"testEnvironment": "node",
21-
"testMatch": [
22-
"**/__tests__/**/?(*.)+(spec|test).ts"
23-
],
24-
"transform": {
25-
"\\.(ts|tsx)$": "@sucrase/jest-plugin"
26-
}
27-
},
2815
"scripts": {
2916
"type": "tsc --noEmit",
3017
"lint": "prettier -c '**/*.{ts,js,json,md,yml,yaml}' '!packages/*/dist/**' '!svg-only/dist/**'",
31-
"test": "jest --verbose --no-cache",
3218
"dev:demo": "( cd packages/demo ; npm run dev )",
3319
"build:demo": "( cd packages/demo ; npm run build )",
3420
"build:action": "( cd packages/action ; npm run build )"

packages/action/__tests__/generateContributionSnake.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import * as fs from "fs";
22
import * as path from "path";
3+
import { it, expect } from "bun:test";
34
import { generateContributionSnake } from "../generateContributionSnake";
45
import { parseOutputsOption } from "../outputsOptions";
5-
import { config } from "dotenv";
6-
config({ path: __dirname + "/../../../.env" });
7-
8-
jest.setTimeout(2 * 60 * 1000);
96

107
const silent = (handler: () => void | Promise<void>) => async () => {
118
const originalConsoleLog = console.log;
@@ -43,5 +40,6 @@ it(
4340
fs.writeFileSync(outputs[0]!.filename, results[0]!);
4441
fs.writeFileSync(outputs[1]!.filename, results[1]!);
4542
fs.writeFileSync(outputs[2]!.filename, results[2]!);
46-
})
43+
}),
44+
{ timeout: 2 * 60 * 1000 }
4745
);

packages/action/__tests__/outputsOptions.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { parseEntry } from "../outputsOptions";
2+
import { it, expect } from "bun:test";
23

34
it("should parse options as json", () => {
45
expect(

packages/demo/webpack.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import path from "path";
22
import HtmlWebpackPlugin from "html-webpack-plugin";
33
import webpack from "webpack";
44
import { getGithubUserContribution } from "@snk/github-user-contribution";
5-
import { config } from "dotenv";
65
import type { Configuration as WebpackConfiguration } from "webpack";
76
import {
87
ExpressRequestHandler,
98
type Configuration as WebpackDevServerConfiguration,
109
} from "webpack-dev-server";
11-
config({ path: __dirname + "/../../.env" });
1210

1311
const demos: string[] = require("./demo.json");
1412

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import * as fs from "fs";
22
import * as path from "path";
3+
import { it, expect } from "bun:test";
34
import { AnimationOptions, createGif } from "..";
45
import * as grids from "@snk/types/__fixtures__/grid";
56
import { snake3 as snake } from "@snk/types/__fixtures__/snake";
67
import { createSnakeFromCells, nextSnake } from "@snk/types/snake";
78
import { getBestRoute } from "@snk/solver/getBestRoute";
89
import type { Options as DrawOptions } from "@snk/draw/drawWorld";
910

10-
jest.setTimeout(20 * 1000);
11-
1211
const upscale = 1;
1312
const drawOptions: DrawOptions = {
1413
sizeDotBorderRadius: 2 * upscale,
@@ -35,10 +34,46 @@ for (const key of [
3534
"small",
3635
"smallPacked",
3736
] as const)
38-
it(`should generate ${key} gif`, async () => {
39-
const grid = grids[key];
37+
it(
38+
`should generate ${key} gif`,
39+
async () => {
40+
const grid = grids[key];
41+
42+
const chain = [snake, ...getBestRoute(grid, snake)!];
43+
44+
const gif = await createGif(
45+
grid,
46+
null,
47+
chain,
48+
drawOptions,
49+
animationOptions
50+
);
51+
52+
expect(gif).toBeDefined();
53+
54+
fs.writeFileSync(path.resolve(dir, key + ".gif"), gif);
55+
},
56+
{ timeout: 20 * 1000 }
57+
);
58+
59+
it(
60+
`should generate swipper`,
61+
async () => {
62+
const grid = grids.smallFull;
63+
let snk = createSnakeFromCells(
64+
Array.from({ length: 6 }, (_, i) => ({ x: i, y: -1 }))
65+
);
4066

41-
const chain = [snake, ...getBestRoute(grid, snake)!];
67+
const chain = [snk];
68+
for (let y = -1; y < grid.height; y++) {
69+
snk = nextSnake(snk, 0, 1);
70+
chain.push(snk);
71+
72+
for (let x = grid.width - 1; x--; ) {
73+
snk = nextSnake(snk, (y + 100) % 2 ? 1 : -1, 0);
74+
chain.push(snk);
75+
}
76+
}
4277

4378
const gif = await createGif(
4479
grid,
@@ -50,29 +85,7 @@ for (const key of [
5085

5186
expect(gif).toBeDefined();
5287

53-
fs.writeFileSync(path.resolve(dir, key + ".gif"), gif);
54-
});
55-
56-
it(`should generate swipper`, async () => {
57-
const grid = grids.smallFull;
58-
let snk = createSnakeFromCells(
59-
Array.from({ length: 6 }, (_, i) => ({ x: i, y: -1 }))
60-
);
61-
62-
const chain = [snk];
63-
for (let y = -1; y < grid.height; y++) {
64-
snk = nextSnake(snk, 0, 1);
65-
chain.push(snk);
66-
67-
for (let x = grid.width - 1; x--; ) {
68-
snk = nextSnake(snk, (y + 100) % 2 ? 1 : -1, 0);
69-
chain.push(snk);
70-
}
71-
}
72-
73-
const gif = await createGif(grid, null, chain, drawOptions, animationOptions);
74-
75-
expect(gif).toBeDefined();
76-
77-
fs.writeFileSync(path.resolve(dir, "swipper.gif"), gif);
78-
});
88+
fs.writeFileSync(path.resolve(dir, "swipper.gif"), gif);
89+
},
90+
{ timeout: 20 * 1000 }
91+
);

packages/github-user-contribution/__tests__/getGithubUserContribution.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { getGithubUserContribution } from "..";
2-
import { config } from "dotenv";
3-
config({ path: __dirname + "/../../../.env" });
2+
import { describe, it, expect } from "bun:test";
43

54
describe("getGithubUserContribution", () => {
65
const promise = getGithubUserContribution("platane", {

packages/solver/__tests__/getBestRoute-fuzz.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { it, expect } from "bun:test";
12
import { getBestRoute } from "../getBestRoute";
23
import { snake3, snake4 } from "@snk/types/__fixtures__/snake";
34
import {

packages/solver/__tests__/getBestRoute.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { it, expect } from "bun:test";
12
import { getBestRoute } from "../getBestRoute";
23
import { Color, createEmptyGrid, setColor } from "@snk/types/grid";
34
import { createSnakeFromCells, snakeToCells } from "@snk/types/snake";

packages/solver/__tests__/getPathTo.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { it, expect } from "bun:test";
12
import { createEmptyGrid } from "@snk/types/grid";
23
import { getHeadX, getHeadY } from "@snk/types/snake";
34
import { snake3 } from "@snk/types/__fixtures__/snake";

0 commit comments

Comments
 (0)