Skip to content

Commit f2708f8

Browse files
committed
Add integration for Deno bdd and @effection-contrib/test-adapter
1 parent 748fb62 commit f2708f8

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

deno.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"compile": "deno compile -o lspx --allow-env --allow-run main.ts"
77
},
88
"imports": {
9+
"@effection-contrib/test-adapter": "jsr:@effection-contrib/test-adapter@^0.1.0",
10+
"@std/testing": "jsr:@std/testing@^1.0.9",
911
"effection": "jsr:@effection/effection@^4.0.0-alpha.7",
1012
"@std/assert": "jsr:@std/assert@1",
1113
"vscode-jsonrpc": "npm:vscode-jsonrpc@^8.2.1",

deno.lock

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/bdd.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {
2+
createTestAdapter,
3+
type TestAdapter,
4+
} from "@effection-contrib/test-adapter";
5+
6+
import * as bdd from "@std/testing/bdd";
7+
8+
export interface EffectionTestContext {
9+
["@effectionx/test-adapter"]: TestAdapter;
10+
}
11+
12+
export function describe(name: string, body: () => void) {
13+
return bdd.describe(name, () => {
14+
bdd.beforeAll<EffectionTestContext>(function () {
15+
let parent = this["@effectionx/test-adapter"];
16+
this["@effectionx/test-adapter"] = createTestAdapter({ name, parent });
17+
});
18+
bdd.afterAll<EffectionTestContext>(async function () {
19+
let current = this["@effectionx/test-adapter"];
20+
this["@effectionx/test-adapter"] = current.parent!;
21+
await current.destroy();
22+
});
23+
body();
24+
});
25+
}
26+
27+
export type BeforeEachArgs = Parameters<TestAdapter["addSetup"]>
28+
29+
export function beforeEach(...args: BeforeEachArgs): void {
30+
bdd.beforeEach<EffectionTestContext>(function() {
31+
this["@effectionx/test-adapter"].addSetup(...args);
32+
});
33+
}
34+
35+
export type ItBody = Parameters<TestAdapter["runTest"]>[0];
36+
37+
export function it(name: string, body: ItBody): void {
38+
bdd.it<EffectionTestContext>(name, function() {
39+
return this["@effectionx/test-adapter"].runTest(body);
40+
})
41+
}

test/lspx.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { beforeEach, describe, it } from "./bdd.ts";
2+
3+
describe("lspx", function () {
4+
beforeEach(function* () {
5+
/* start a multiplexed server */
6+
});
7+
it("returns the capabilities of all multiplexed servers", function* () {
8+
});
9+
});

0 commit comments

Comments
 (0)