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

Commit

Permalink
fix: pull in preconfigured chai from interface tests
Browse files Browse the repository at this point in the history
This is to work around chaijs/chai#1298

Fundamentally we cannot pull in chai and add plugins to it without
being careful of the order of those plugins as it's a singleton.

All we're really interested in is the `expect` function to just
get the preconfigured one from the interface tests.
  • Loading branch information
achingbrain committed Oct 4, 2019
1 parent 55e64d4 commit 6a7eb8a
Show file tree
Hide file tree
Showing 21 changed files with 20 additions and 106 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@
"devDependencies": {
"aegir": "^20.3.1",
"browser-process-platform": "~0.1.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cross-env": "^6.0.0",
"dirty-chai": "^2.0.1",
"go-ipfs-dep": "^0.4.22",
"interface-ipfs-core": "^0.115.0",
"ipfsd-ctl": "^0.47.1",
Expand Down
7 changes: 1 addition & 6 deletions test/commands.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const ipfsClient = require('../src')

const f = require('./utils/factory')

describe('.commands', function () {
Expand Down
6 changes: 1 addition & 5 deletions test/constructor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
'use strict'

const multiaddr = require('multiaddr')
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const f = require('./utils/factory')
const ipfsClient = require('../src/index.js')

Expand Down
6 changes: 1 addition & 5 deletions test/custom-headers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
'use strict'

const isNode = require('detect-node')
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const ipfsClient = require('../src')
const f = require('./utils/factory')

Expand Down
7 changes: 1 addition & 6 deletions test/dag.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@

'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const chaiAsPromised = require('chai-as-promised')
const expect = chai.expect
chai.use(dirtyChai)
chai.use(chaiAsPromised)
const { expect } = require('interface-ipfs-core/src/utils/mocha')
const { DAGNode } = require('ipld-dag-pb')
const CID = require('cids')
const ipfsClient = require('../src')
Expand Down
6 changes: 1 addition & 5 deletions test/diag.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('interface-ipfs-core/src/utils/mocha')
const platform = require('browser-process-platform')

const ipfsClient = require('../src')
const f = require('./utils/factory')

Expand Down
6 changes: 1 addition & 5 deletions test/endpoint-config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('interface-ipfs-core/src/utils/mocha')
const isNode = require('detect-node')

const ipfsClient = require('../src')
const f = require('./utils/factory')

Expand Down
5 changes: 1 addition & 4 deletions test/exports.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const multicodec = require('multicodec')
const multihash = require('multihashes')
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('interface-ipfs-core/src/utils/mocha')

const IpfsHttpClient = require('../')

Expand Down
7 changes: 1 addition & 6 deletions test/files-mfs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const chaiAsPromised = require('chai-as-promised')
const expect = chai.expect
chai.use(dirtyChai)
chai.use(chaiAsPromised)
const { expect } = require('interface-ipfs-core/src/utils/mocha')
const loadFixture = require('aegir/fixtures')
const mh = require('multihashes')
const CID = require('cids')
Expand Down
7 changes: 1 addition & 6 deletions test/get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@

'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const chaiAsPromised = require('chai-as-promised')
const expect = chai.expect
chai.use(dirtyChai)
chai.use(chaiAsPromised)
const { expect } = require('interface-ipfs-core/src/utils/mocha')
const loadFixture = require('aegir/fixtures')

const ipfsClient = require('../src')
Expand Down
6 changes: 1 addition & 5 deletions test/key.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const ipfsClient = require('../src')
const f = require('./utils/factory')

Expand Down
6 changes: 1 addition & 5 deletions test/lib.configure.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/* eslint-env mocha, browser */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('interface-ipfs-core/src/utils/mocha')
const Multiaddr = require('multiaddr')
const { isBrowser, isWebWorker } = require('ipfs-utils/src/env')

const configure = require('../src/lib/configure')

describe('lib/configure', () => {
Expand Down
5 changes: 1 addition & 4 deletions test/lib.error-handler.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const { expect } = require('interface-ipfs-core/src/utils/mocha')
const { HTTPError } = require('ky-universal')
const expect = chai.expect
chai.use(dirtyChai)
const throwsAsync = require('./utils/throws-async')
const errorHandler = require('../src/lib/error-handler')

Expand Down
5 changes: 1 addition & 4 deletions test/lib.stream-to-iterable.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('interface-ipfs-core/src/utils/mocha')
const toIterable = require('../src/lib/stream-to-iterable')

describe('lib/stream-to-iterable', () => {
Expand Down
6 changes: 1 addition & 5 deletions test/log.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const ipfsClient = require('../src')
const f = require('./utils/factory')

Expand Down
8 changes: 1 addition & 7 deletions test/node/swarm.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
/* eslint-env mocha */
'use strict'

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const nock = require('nock')
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const chaiAsPromised = require('chai-as-promised')
const expect = chai.expect
chai.use(dirtyChai)
chai.use(chaiAsPromised)

const ipfsClient = require('../../src')

describe('.swarm.peers', function () {
Expand Down
7 changes: 1 addition & 6 deletions test/ping.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const chaiAsPromised = require('chai-as-promised')
const expect = chai.expect
chai.use(dirtyChai)
chai.use(chaiAsPromised)
const { expect } = require('interface-ipfs-core/src/utils/mocha')
const pull = require('pull-stream/pull')
const collect = require('pull-stream/sinks/collect')

Expand Down
6 changes: 1 addition & 5 deletions test/repo.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const ipfsClient = require('../src')
const f = require('./utils/factory')

Expand Down
5 changes: 1 addition & 4 deletions test/request-api.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('interface-ipfs-core/src/utils/mocha')
const isNode = require('detect-node')
const ipfsClient = require('../src/index.js')
const ndjson = require('ndjson')
Expand Down
6 changes: 1 addition & 5 deletions test/stats.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const ipfsClient = require('../src')
const f = require('./utils/factory')

Expand Down
6 changes: 1 addition & 5 deletions test/sub-modules.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const defaultConfig = require('../src/utils/default-config.js')
const config = defaultConfig()
config.host = 'test'
Expand Down

0 comments on commit 6a7eb8a

Please sign in to comment.