Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
chore: run all tests in all environments
Browse files Browse the repository at this point in the history
Remove repo, block service and other unecessary deps.
  • Loading branch information
achingbrain authored and vmx committed Aug 4, 2020
1 parent 2047488 commit a1c73bc
Show file tree
Hide file tree
Showing 20 changed files with 615 additions and 841 deletions.
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,18 @@
"npm": ">=3.0.0"
},
"dependencies": {
"cids": "multiformats/js-cid#fix/support-uint8arrays",
"cids": "^1.0.0",
"class-is": "^1.1.0",
"multicodec": "^2.0.0",
"multihashing-async": "^2.0.0",
"npm": "^6.14.7",
"protons": "^1.2.1",
"protons": "^2.0.0",
"reset": "^0.1.0",
"run": "^1.4.0",
"stable": "^0.1.8",
"uint8arrays": "^1.0.0"
},
"devDependencies": {
"aegir": "^25.0.0",
"fs-extra": "^9.0.1",
"ipfs-block-service": "^0.17.1",
"ipfs-repo": "^5.0.0",
"ipfs-utils": "^2.3.1",
"ipld-block": "^0.9.2",
"multibase": "^3.0.0",
"multihashes": "^3.0.0"
}
Expand Down
30 changes: 0 additions & 30 deletions test/browser.js

This file was deleted.

68 changes: 0 additions & 68 deletions test/dag-link-test.js

This file was deleted.

66 changes: 66 additions & 0 deletions test/dag-link-test.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* eslint-env mocha */
'use strict'

const chai = require('aegir/utils/chai')
const expect = chai.expect
const CID = require('cids')
const DAGLink = require('../src').DAGLink
const uint8ArrayFromString = require('uint8arrays/from-string')
const uint8ArrayToString = require('uint8arrays/to-string')

describe('DAGLink', () => {
describe('create with multihash as b58 encoded string', () => {
it('string', () => {
const link = new DAGLink('hello', 3, 'QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39U')

expect(uint8ArrayToString(link.Hash.bytes, 'base16'))
.to.equal('12208ab7a6c5e74737878ac73863cb76739d15d4666de44e5756bf55a2f9e9ab5f43')
})

it('empty string', () => {
const link = new DAGLink('', 4, 'QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39U')
expect(link.Name).to.be.eql('')
})

it('create with multihash as a multihash Buffer', () => {
const link = new DAGLink('hello', 3, uint8ArrayFromString('12208ab7a6c5e74737878ac73863cb76739d15d4666de44e5756bf55a2f9e9ab5f43', 'base16'))

expect(new CID(link.Hash).toBaseEncodedString())
.to.equal('QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39U')
})

it('fail to create without multihash', () => {
expect(() => {
const link = new DAGLink('hello', 3)
expect(link).to.not.exist()
}).to.throw()
})
})

it('toJSON', () => {
const link = new DAGLink('hello', 3, 'QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39U')

expect(link.toJSON()).to.eql({
name: 'hello',
size: 3,
cid: 'QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39U'
})
})

it('toString', () => {
const link = new DAGLink('hello', 3, 'QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39U')

expect(link.toString()).to.equal('DAGLink <QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39U - name: "hello", size: 3>')
})

it('exposes a CID', () => {
const cid = 'QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39U'
const link = new DAGLink('hello', 3, cid)
expect(link.Hash.toBaseEncodedString()).to.equal(cid)
})

it('has an immutable CID', () => {
const link = new DAGLink('hello', 3, 'QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39U')
expect(() => { link.Hash = 'foo' }).to.throw(/read.only/)
})
})
Loading

0 comments on commit a1c73bc

Please sign in to comment.