mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-07 03:11:17 +00:00
fix: add async support to setup (#11)
This commit is contained in:
parent
6bb1f2a4cb
commit
2814c76e23
@ -38,10 +38,10 @@ Include this badge in your readme if you make a new module that uses interface-p
|
|||||||
|
|
||||||
### Node.js
|
### Node.js
|
||||||
|
|
||||||
Install `interface-peer-discovery` as one of the dependencies of your project and as a test file. Then, using `mocha` (for JavaScript) or a test runner with compatible API, do:
|
Install `interface-discovery` as one of the dependencies of your project and as a test file. Then, using `mocha` (for JavaScript) or a test runner with compatible API, do:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const test = require('interface-peer-discovery')
|
const test = require('interface-discovery')
|
||||||
|
|
||||||
const common = {
|
const common = {
|
||||||
setup () {
|
setup () {
|
||||||
|
@ -5,12 +5,14 @@ module.exports = (common) => {
|
|||||||
describe('interface-peer-discovery', () => {
|
describe('interface-peer-discovery', () => {
|
||||||
let discovery
|
let discovery
|
||||||
|
|
||||||
before(() => {
|
before(async () => {
|
||||||
discovery = common.setup()
|
discovery = await common.setup()
|
||||||
})
|
})
|
||||||
|
|
||||||
after(() => common.teardown && common.teardown())
|
after(() => common.teardown && common.teardown())
|
||||||
|
|
||||||
|
afterEach('ensure discovery was stopped', () => discovery.stop())
|
||||||
|
|
||||||
it('can start the service', async () => {
|
it('can start the service', async () => {
|
||||||
await discovery.start()
|
await discovery.start()
|
||||||
})
|
})
|
||||||
|
@ -6,8 +6,12 @@ const MockDiscovery = require('./mock-discovery')
|
|||||||
|
|
||||||
describe('compliance tests', () => {
|
describe('compliance tests', () => {
|
||||||
tests({
|
tests({
|
||||||
setup () {
|
async setup () {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 10))
|
||||||
return new MockDiscovery()
|
return new MockDiscovery()
|
||||||
|
},
|
||||||
|
async teardown () {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 10))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user