Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
chore: fix up message port client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Sep 23, 2020
1 parent b03ebef commit f1371a1
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 62 deletions.
2 changes: 0 additions & 2 deletions packages/interface-ipfs-core/src/dag/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,11 @@ module.exports = (common, options) => {
it('should throw error for invalid string CID input', () => {
return expect(ipfs.dag.get('INVALID CID'))
.to.eventually.be.rejected()
.and.to.have.property('code').that.equals('ERR_INVALID_CID')
})

it('should throw error for invalid buffer CID input', () => {
return expect(ipfs.dag.get(uint8ArrayFromString('INVALID CID')))
.to.eventually.be.rejected()
.and.to.have.property('code').that.equals('ERR_INVALID_CID')
})
})
}
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/src/utils/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function getDescribe (config) {
return describe.skip(`${name} (${skip.reason})`, impl)
}

return describe
describe(name, impl)
}

_describe.skip = describe.skip
Expand Down
6 changes: 2 additions & 4 deletions packages/ipfs-message-port-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
"url": "git+https://github.com/ipfs/js-ipfs.git"
},
"scripts": {
"test": "npm run test:browser",
"test:browser": "npm run build:test-worker && aegir test -t browser",
"test:chrome": "aegir test -t browser -- --browsers ChromeHeadless",
"test:firefox": "aegir test -t browser -- --browsers FirefoxHeadless",
"test": "echo 'Only interface tests live here'",
"test:interface:core:browser": "aegir test -t browser",
"lint": "aegir lint",
"build:test-worker": "aegir build -- --config ./test/util/webpack.config.js",
"build": "aegir build",
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-message-port-client/src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CoreClient extends Client {
* @param {Transport} transport
*/
constructor (transport) {
super('core', ['add', 'cat'], transport)
super('core', ['add', 'addAll', 'cat'], transport)
}

/**
Expand Down
9 changes: 0 additions & 9 deletions packages/ipfs-message-port-client/test/interface.core.js

This file was deleted.

110 changes: 73 additions & 37 deletions packages/ipfs-message-port-client/test/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,17 @@
'use strict'

const tests = require('interface-ipfs-core')
const { core } = require('./interface.core')
const { activate } = require('./util/client')

describe('interface-ipfs-core tests', () => {
const commonFactory = {
const factory = {
spawn () {
return { api: activate() }
},
clean () {}
}

tests.dag(commonFactory, {
skip: [
{
name: 'should get a dag-pb node',
reason: 'Nodes are not turned into dag-pb DAGNode instances'
},
{
name: 'should get a dag-pb node with path',
reason: 'Nodes are not turned into dag-pb DAGNode instances'
},
{
name: 'should get by CID string',
reason: 'Passing CID as strings is not supported'
},
{
name: 'should get by CID string + path',
reason: 'Passing CID as strings is not supported'
},
{
name: 'should get a node added as CIDv1 with a CIDv0',
reason: 'ipfs.block API is not implemented'
},
{
name: 'should be able to get part of a dag-cbor node',
reason: 'Passing CID as strings is not supported'
},
{
name: 'should get tree with CID and path as String',
reason: 'Passing CID as strings is not supported'
}
]
})

core(commonFactory, {
tests.root(factory, {
skip: [
{
name: 'should add with only-hash=true',
Expand Down Expand Up @@ -91,11 +57,68 @@ describe('interface-ipfs-core tests', () => {
{
name: 'should not add from an invalid url',
reason: 'https://github.com/ipfs/js-ipfs/issues/3195'
},
{
name: 'should be able to add dir without sharding',
reason: 'Cannot spawn IPFS with different args'
},
{
name: 'addAll',
reason: 'Not implemented'
},
{
name: 'get',
reason: 'Not implemented'
},
{
name: 'ls',
reason: 'Not implemented'
},
{
name: 'refs',
reason: 'Not implemented'
},
{
name: 'refsLocal',
reason: 'Not implemented'
}
]
})

tests.block(commonFactory, {
tests.dag(factory, {
skip: [
{
name: 'should get a dag-pb node',
reason: 'Nodes are not turned into dag-pb DAGNode instances'
},
{
name: 'should get a dag-pb node with path',
reason: 'Nodes are not turned into dag-pb DAGNode instances'
},
{
name: 'should get by CID string',
reason: 'Passing CID as strings is not supported'
},
{
name: 'should get by CID string + path',
reason: 'Passing CID as strings is not supported'
},
{
name: 'should get a node added as CIDv1 with a CIDv0',
reason: 'ipfs.block API is not implemented'
},
{
name: 'should be able to get part of a dag-cbor node',
reason: 'Passing CID as strings is not supported'
},
{
name: 'should get tree with CID and path as String',
reason: 'Passing CID as strings is not supported'
}
]
})

tests.block(factory, {
skip: [
{
name: 'should get by CID in string',
Expand Down Expand Up @@ -128,6 +151,19 @@ describe('interface-ipfs-core tests', () => {
{
name: 'should error when removing pinned blocks',
reason: 'ipfs.pin.add is not implemented'
},

{
name: 'should remove multiple CIDs',
reason: 'times out'
},
{
name: 'should error when removing non-existent blocks',
reason: 'times out'
},
{
name: 'should not error when force removing non-existent blocks',
reason: 'times out'
}
]
})
Expand Down
10 changes: 2 additions & 8 deletions packages/ipfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@
"lint": "aegir lint",
"build": "aegir build",
"test": "echo 'Only interface tests live here'",
"test:interface:core:node": "aegir test -f test/core/interface.spec.js -- -t node",
"test:interface:core:browser": "aegir test -f test/core/interface.spec.js -- -t browser",
"test:interface:core:electron-main": "aegir test -f test/core/interface.spec.js -- -t electron-main",
"test:interface:core:electron-renderer": "aegir test -f test/core/interface.spec.js -- -t electron-renderer",
"test:interface:http:node": "aegir test -f test/http-api/interface.js -- -t node",
"test:interface:http:browser": "aegir test -f test/http-api/interface.js -- -t browser",
"test:interface:http:electron-main": "aegir test -f test/http-api/interface.js -- -t electron-main",
"test:interface:http:electron-renderer": "aegir test -f test/http-api/interface.js -- -t electron-renderer",
"test:interface:core": "aegir test -f test/interface-core.js",
"test:interface:http": "aegir test -f test/http-api/interface-http.js -- -t node",
"test:interop": "cross-env IPFS_JS_EXEC=$PWD/src/cli.js IPFS_JS_MODULE=$PWD IPFS_JS_HTTP_MODULE=$PWD/../ipfs-http-client IPFS_REUSEPORT=false ipfs-interop",
"test:interop:node": "cross-env IPFS_JS_EXEC=$PWD/src/cli.js IPFS_JS_MODULE=$PWD IPFS_JS_HTTP_MODULE=$PWD/../ipfs-http-client IPFS_REUSEPORT=false ipfs-interop -- -t node",
"test:interop:browser": "cross-env IPFS_JS_EXEC=$PWD/src/cli.js IPFS_JS_MODULE=$PWD IPFS_JS_HTTP_MODULE=$PWD/../ipfs-http-client IPFS_REUSEPORT=false ipfs-interop -- -t browser",
Expand Down

0 comments on commit f1371a1

Please sign in to comment.