Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit 2814c76

Browse files
jacobheunvasco-santos
authored andcommitted
fix: add async support to setup (#11)
1 parent 6bb1f2a commit 2814c76

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ Include this badge in your readme if you make a new module that uses interface-p
3838

3939
### Node.js
4040

41-
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:
41+
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:
4242

4343
```js
44-
const test = require('interface-peer-discovery')
44+
const test = require('interface-discovery')
4545

4646
const common = {
4747
setup () {

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ module.exports = (common) => {
55
describe('interface-peer-discovery', () => {
66
let discovery
77

8-
before(() => {
9-
discovery = common.setup()
8+
before(async () => {
9+
discovery = await common.setup()
1010
})
1111

1212
after(() => common.teardown && common.teardown())
1313

14+
afterEach('ensure discovery was stopped', () => discovery.stop())
15+
1416
it('can start the service', async () => {
1517
await discovery.start()
1618
})

test/compliance.spec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ const MockDiscovery = require('./mock-discovery')
66

77
describe('compliance tests', () => {
88
tests({
9-
setup () {
9+
async setup () {
10+
await new Promise(resolve => setTimeout(resolve, 10))
1011
return new MockDiscovery()
12+
},
13+
async teardown () {
14+
await new Promise(resolve => setTimeout(resolve, 10))
1115
}
1216
})
1317
})

0 commit comments

Comments
 (0)