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

Commit 187c89e

Browse files
author
Pedro Santos
committed
refactor: object before and after methods to async syntax
1 parent 03b5d6f commit 187c89e

File tree

10 files changed

+30
-140
lines changed

10 files changed

+30
-140
lines changed

src/object/data.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,11 @@ module.exports = (createCommon, options) => {
1616

1717
let ipfs
1818

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

34-
after((done) => common.teardown(done))
23+
after(() => common.teardown())
3524

3625
it('should get data by multihash', async () => {
3726
const testObj = {

src/object/get.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,11 @@ module.exports = (createCommon, options) => {
1919

2020
let ipfs
2121

22-
before(function (done) {
23-
// CI takes longer to instantiate the daemon, so we need to increase the
24-
// timeout for the before step
25-
this.timeout(60 * 1000)
26-
27-
common.setup((err, factory) => {
28-
expect(err).to.not.exist()
29-
factory.spawnNode((err, node) => {
30-
expect(err).to.not.exist()
31-
ipfs = node
32-
done()
33-
})
34-
})
22+
before(async () => {
23+
ipfs = await common.setup()
3524
})
3625

37-
after((done) => common.teardown(done))
26+
after(() => common.teardown())
3827

3928
it('should get object by multihash', async () => {
4029
const obj = {

src/object/links.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,11 @@ module.exports = (createCommon, options) => {
1919

2020
let ipfs
2121

22-
before(function (done) {
23-
// CI takes longer to instantiate the daemon, so we need to increase the
24-
// timeout for the before step
25-
this.timeout(60 * 1000)
26-
27-
common.setup((err, factory) => {
28-
expect(err).to.not.exist()
29-
factory.spawnNode((err, node) => {
30-
expect(err).to.not.exist()
31-
ipfs = node
32-
done()
33-
})
34-
})
22+
before(async () => {
23+
ipfs = await common.setup()
3524
})
3625

37-
after((done) => common.teardown(done))
26+
after(() => common.teardown())
3827

3928
it('should get empty links by multihash', async () => {
4029
const testObj = {

src/object/new.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,11 @@ module.exports = (createCommon, options) => {
1313

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 create a new object with no template', async () => {
3423
const cid = await ipfs.object.new()

src/object/patch/add-link.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,11 @@ module.exports = (createCommon, options) => {
1616

1717
let ipfs
1818

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

34-
after((done) => common.teardown(done))
23+
after(() => common.teardown())
3524

3625
it('should add a link to an existing node', async () => {
3726
const obj = {

src/object/patch/append-data.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,11 @@ module.exports = (createCommon, options) => {
1414

1515
let ipfs
1616

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

32-
after((done) => common.teardown(done))
21+
after(() => common.teardown())
3322

3423
it('should append data to an existing node', async () => {
3524
const obj = {

src/object/patch/rm-link.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,11 @@ module.exports = (createCommon, options) => {
1414

1515
let ipfs
1616

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

32-
after((done) => common.teardown(done))
21+
after(() => common.teardown())
3322

3423
it('should remove a link from an existing node', async () => {
3524
const obj1 = {

src/object/patch/set-data.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,11 @@ module.exports = (createCommon, options) => {
1414

1515
let ipfs
1616

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

32-
after((done) => common.teardown(done))
21+
after(() => common.teardown())
3322

3423
it('should set data for an existing node', async () => {
3524
const obj = {

src/object/put.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,11 @@ module.exports = (createCommon, options) => {
1717

1818
let ipfs
1919

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

35-
after((done) => common.teardown(done))
24+
after(() => common.teardown())
3625

3726
it('should put an object', async () => {
3827
const obj = {

src/object/stat.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,11 @@ module.exports = (createCommon, options) => {
1717

1818
let ipfs
1919

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

35-
after((done) => common.teardown(done))
24+
after(() => common.teardown())
3625

3726
it('should get stats by multihash', async () => {
3827
const testObj = {

0 commit comments

Comments
 (0)