generated from well-known-components/template-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
components.ts
31 lines (25 loc) · 947 Bytes
/
components.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// This file is the "test-environment" analogous for src/components.ts
// Here we define the test components to be used in the testing environment
import { createRunner, createLocalFetchCompoment } from "@well-known-components/test-helpers"
import { main } from "../src/service"
import { TestComponents } from "../src/types"
import { initComponents as originalInitComponents } from "../src/components"
/**
* Behaves like Jest "describe" function, used to describe a test for a
* use case, it creates a whole new program and components to run an
* isolated test.
*
* State is persistent within the steps of the test.
*/
export const test = createRunner<TestComponents>({
main,
initComponents,
})
async function initComponents(): Promise<TestComponents> {
const components = await originalInitComponents()
const { config } = components
return {
...components,
localFetch: await createLocalFetchCompoment(config),
}
}