-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
executable file
·50 lines (31 loc) · 1.15 KB
/
test.js
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
47
48
49
50
#!/usr/bin/env -S node --experimental-vm-modules
import assert from 'node:assert'
import Agregore from './index.js'
const agregore = await new Agregore()
await agregore.init()
const toFetch = 'https://blog.mauve.moe/esm.js'
await assert.doesNotReject(async () => {
const response = await agregore.fetch(toFetch)
assert(response.ok, 'Able to fetch from HTTPS')
console.log(await response.text())
}, 'Able to fetch')
await assert.doesNotThrow(() => {
const result = agregore.eval('400 + 20')
assert.equal(result, 420, 'Got correct result from eval')
}, 'Able to evaluate JS')
await assert.doesNotReject(async () => {
const module = await agregore.import(toFetch)
module.default()
}, 'Able to import module')
await assert.doesNotReject(async () => {
const p2pURL = 'hyper://blog.mauve.moe/esm.js'
const module = await agregore.import(p2pURL)
module.default()
}, 'Able to import module from hyper://')
await assert.doesNotReject(async () => {
const p2pURL = 'ipns://blog.mauve.moe/esm.js'
const module = await agregore.import(p2pURL)
module.default()
}, 'Able to import module from ipns://')
await agregore.close()
console.log('Done!')