Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 444c6a5

Browse files
author
Pedro Santos
committed
refactor: config before and after methods to async syntax
1 parent 20e842b commit 444c6a5

File tree

5 files changed

+19
-74
lines changed

5 files changed

+19
-74
lines changed

src/config/get.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,14 @@ module.exports = (createCommon, options) => {
1010
const common = createCommon()
1111

1212
describe('.config.get', function () {
13-
this.timeout(30 * 1000)
13+
this.timeout(60 * 1000)
1414
let ipfs
1515

16-
before(function (done) {
17-
// CI takes longer to instantiate the daemon, so we need to increase the
18-
// timeout for the before step
19-
this.timeout(60 * 1000)
20-
21-
common.setup((err, factory) => {
22-
expect(err).to.not.exist()
23-
factory.spawnNode((err, node) => {
24-
expect(err).to.not.exist()
25-
ipfs = node
26-
done()
27-
})
28-
})
16+
before(async () => {
17+
ipfs = await common.setup()
2918
})
3019

31-
after((done) => common.teardown(done))
20+
after(() => common.teardown())
3221

3322
it('should retrieve the whole config', async () => {
3423
const config = await ipfs.config.get()

src/config/profiles/apply.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,11 @@ module.exports = (createCommon, options) => {
1212
this.timeout(30 * 1000)
1313
let ipfs
1414

15-
before(function (done) {
16-
// CI takes longer to instantiate the daemon, so we need to increase the
17-
// timeout for the before step
18-
this.timeout(60 * 1000)
19-
20-
common.setup((err, factory) => {
21-
expect(err).to.not.exist()
22-
factory.spawnNode((err, node) => {
23-
expect(err).to.not.exist()
24-
ipfs = node
25-
done()
26-
})
27-
})
15+
before(async () => {
16+
ipfs = await common.setup()
2817
})
2918

30-
after((done) => common.teardown(done))
19+
after(() => common.teardown())
3120

3221
it('should apply a config profile', async () => {
3322
const diff = await ipfs.config.profiles.apply('lowpower')

src/config/profiles/list.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,14 @@ module.exports = (createCommon, options) => {
99
const common = createCommon()
1010

1111
describe('.config.profiles.list', function () {
12-
this.timeout(30 * 1000)
12+
this.timeout(60 * 1000)
1313
let ipfs
1414

15-
before(function (done) {
16-
// CI takes longer to instantiate the daemon, so we need to increase the
17-
// timeout for the before step
18-
this.timeout(60 * 1000)
19-
20-
common.setup((err, factory) => {
21-
expect(err).to.not.exist()
22-
factory.spawnNode((err, node) => {
23-
expect(err).to.not.exist()
24-
ipfs = node
25-
done()
26-
})
27-
})
15+
before(async () => {
16+
ipfs = await common.setup()
2817
})
2918

30-
after((done) => common.teardown(done))
19+
after(() => common.teardown())
3120

3221
it('should list config profiles', async () => {
3322
const profiles = await ipfs.config.profiles.list()

src/config/replace.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,14 @@ module.exports = (createCommon, options) => {
99
const common = createCommon()
1010

1111
describe('.config.replace', function () {
12-
this.timeout(30 * 1000)
12+
this.timeout(60 * 1000)
1313
let ipfs
1414

15-
before(function (done) {
16-
// CI takes longer to instantiate the daemon, so we need to increase the
17-
// timeout for the before step
18-
this.timeout(60 * 1000)
19-
20-
common.setup((err, factory) => {
21-
expect(err).to.not.exist()
22-
factory.spawnNode((err, node) => {
23-
expect(err).to.not.exist()
24-
ipfs = node
25-
done()
26-
})
27-
})
15+
before(async () => {
16+
ipfs = await common.setup()
2817
})
2918

30-
after((done) => common.teardown(done))
19+
after(() => common.teardown())
3120

3221
const config = {
3322
Fruit: 'Bananas'

src/config/set.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,14 @@ module.exports = (createCommon, options) => {
99
const common = createCommon()
1010

1111
describe('.config.set', function () {
12-
this.timeout(30 * 1000)
12+
this.timeout(60 * 1000)
1313
let ipfs
1414

15-
before(function (done) {
16-
// CI takes longer to instantiate the daemon, so we need to increase the
17-
// timeout for the before step
18-
this.timeout(60 * 1000)
19-
20-
common.setup((err, factory) => {
21-
expect(err).to.not.exist()
22-
factory.spawnNode((err, node) => {
23-
expect(err).to.not.exist()
24-
ipfs = node
25-
done()
26-
})
27-
})
15+
before(async () => {
16+
ipfs = await common.setup()
2817
})
2918

30-
after((done) => common.teardown(done))
19+
after(() => common.teardown())
3120

3221
it('should set a new key', async () => {
3322
await ipfs.config.set('Fruit', 'banana')

0 commit comments

Comments
 (0)