-
Notifications
You must be signed in to change notification settings - Fork 0
/
wiring.test.tsx
28 lines (26 loc) · 968 Bytes
/
wiring.test.tsx
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
import { JSDOM } from 'jsdom'
import { equal } from 'node:assert/strict'
import { describe, it } from 'node:test'
import { firstValueFrom } from 'rxjs'
import { SimpleComponent } from './component.js'
import { jsx } from './jsx.js'
import { WiringContext } from './wiring-context.js'
import buildDomStrategy from './wiring-dom-build.js'
import { wire } from './wiring.js'
describe('wiring', () => {
it('wires a simple static component', async () => {
const { window } = new JSDOM()
const { document } = window
const example: SimpleComponent = () => <h1>Hello World</h1>
const context: WiringContext = {
domStrategy: buildDomStrategy,
isStaticComponent: true,
isStaticTree: true,
}
const obs = wire(example, context, undefined, document)
const element = (await firstValueFrom(obs)) as HTMLElement
equal(context.isStaticComponent, true)
equal(context.isStaticTree, true)
equal(element.tagName, 'H1')
})
})