This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: run all tests in all environments
Remove repo, block service and other unecessary deps.
- Loading branch information
1 parent
2047488
commit a1c73bc
Showing
20 changed files
with
615 additions
and
841 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/) | ||
}) | ||
}) |
Oops, something went wrong.