Updates
This commit is contained in:
@@ -1,26 +1,36 @@
|
||||
require('bare-process/global')
|
||||
const test = require('brittle')
|
||||
const { HyperP2PBareBundleBridge, PROTOCOL } = require('../index.js')
|
||||
const { HyperBareBundleBridge, PROTOCOL } = require('../index.js')
|
||||
|
||||
test('exports', (t) => {
|
||||
t.ok(HyperP2PBareBundleBridge)
|
||||
t.ok(PROTOCOL)
|
||||
t.ok(HyperBareBundleBridge)
|
||||
t.is(PROTOCOL, 'bare-bundle-bridge/v1')
|
||||
})
|
||||
|
||||
test('basic operation', async (t) => {
|
||||
const m = new HyperP2PBareBundleBridge()
|
||||
m.put('k', 1); t.is(m.get('k'), 1)
|
||||
test('registerBundle resolve', async (t) => {
|
||||
const m = new HyperBareBundleBridge()
|
||||
m.registerBundle('app', { entry: './index.js' })
|
||||
t.is(m.resolve('app').manifest.entry, './index.js')
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('listBundles', async (t) => {
|
||||
const m = new HyperBareBundleBridge()
|
||||
m.registerBundle('a', {})
|
||||
m.registerBundle('b', {})
|
||||
t.is(m.listBundles().length, 2)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('validation', async (t) => {
|
||||
const m = new HyperP2PBareBundleBridge()
|
||||
try { m.put(null, 1) } catch (e) { t.ok(e) }
|
||||
const m = new HyperBareBundleBridge()
|
||||
try { m.registerBundle('x', null) } catch (e) { t.ok(e) }
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('getStats', async (t) => {
|
||||
const m = new HyperP2PBareBundleBridge()
|
||||
t.ok(m.getStats().protocol)
|
||||
const m = new HyperBareBundleBridge()
|
||||
m.registerBundle('z', {})
|
||||
t.is(m.getStats().registered, 1)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user