-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathengine.test.ts
46 lines (40 loc) · 1.62 KB
/
engine.test.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Backchat } from './api/client-backchat.ts'
import guts from './guts/guts.ts'
import { expect, log } from '@utils'
import { cradleMaker } from '@/cradle-maker.ts'
import * as backchat from './isolates/backchat.ts'
import { getBaseName } from '@/constants.ts'
Deno.test('cradle', async (t) => {
await using cradle = await cradleMaker(t, import.meta.url)
const { engine, privateKey, backchat } = cradle
await t.step('basic', async () => {
const result = await backchat.ping({ data: 'hello' })
expect(result).toBe('hello')
await backchat.rm({ repo: 'dreamcatcher-tech/HAL' })
log('backchat', backchat.pid)
const clone = await backchat.clone({ repo: 'dreamcatcher-tech/HAL' })
log('clone result', clone)
expect(clone.pid).toBeDefined()
expect(clone.pid.account).toBe('dreamcatcher-tech')
expect(typeof clone.head).toBe('string')
})
let next: Backchat
await t.step('second backchat', async () => {
next = await Backchat.upsert(engine, privateKey)
expect(next.pid).not.toEqual(backchat.pid)
expect(next.id).not.toEqual(backchat.id)
})
await t.step('new thread', async () => {
const firstBase = await backchat.threadPID()
const secondBase = await next.threadPID()
expect(firstBase).not.toEqual(secondBase)
const { newThread } = await next.actions<backchat.Api>('backchat')
const threadId = await newThread({})
const thirdBase = await next.threadPID()
expect(getBaseName(thirdBase)).toEqual(threadId)
expect(secondBase).not.toEqual(thirdBase)
})
// test intercepting backchat text
})
guts(cradleMaker)
// TODO confirm cannot delete the system chain