@cueloop/extension-api 0.1.0-alpha.20 → 0.1.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/registry.test.ts +10 -0
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cueloop/extension-api",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.22",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./src/index.ts"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@cueloop/schema": "0.1.0-alpha.
|
|
10
|
+
"@cueloop/schema": "0.1.0-alpha.22"
|
|
11
11
|
},
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
package/src/registry.test.ts
CHANGED
|
@@ -6,23 +6,33 @@ const SESSION = { id: "ses_x", annotations: [] } as unknown as ReviewSession;
|
|
|
6
6
|
|
|
7
7
|
describe("Registry", () => {
|
|
8
8
|
test("captures each extension's exporters, attributed by name", async () => {
|
|
9
|
+
// Arrange
|
|
9
10
|
const registry = new Registry();
|
|
11
|
+
|
|
12
|
+
// Act
|
|
10
13
|
await registry.load("obsidian", (api) => {
|
|
11
14
|
api.registerExporter("obsidian", async () => ({ success: true, path: "/vault/note.md" }));
|
|
12
15
|
});
|
|
13
16
|
await registry.load("bear", (api) => {
|
|
14
17
|
api.registerExporter("bear", async () => ({ success: true }));
|
|
15
18
|
});
|
|
19
|
+
|
|
20
|
+
// Assert
|
|
16
21
|
expect(registry.extensions.map((extension) => extension.name)).toEqual(["obsidian", "bear"]);
|
|
17
22
|
const obsidian = registry.extensions[0]!.exporters.get("obsidian")!;
|
|
18
23
|
expect(await obsidian(SESSION)).toEqual({ success: true, path: "/vault/note.md" });
|
|
19
24
|
});
|
|
20
25
|
|
|
21
26
|
test("a throwing factory is contained, not fatal", async () => {
|
|
27
|
+
// Arrange
|
|
22
28
|
const registry = new Registry();
|
|
29
|
+
|
|
30
|
+
// Act
|
|
23
31
|
const record = await registry.load("broken", () => {
|
|
24
32
|
throw new Error("boom");
|
|
25
33
|
});
|
|
34
|
+
|
|
35
|
+
// Assert
|
|
26
36
|
expect(record.errors).toEqual(["boom"]);
|
|
27
37
|
expect(record.exporters.size).toBe(0);
|
|
28
38
|
expect(registry.extensions.length).toBe(1);
|