Skip to content

Commit

Permalink
Add failing tests for recongnizing ipfs:// URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDaub committed Sep 6, 2022
1 parent 393859a commit a5d55d9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/test-path.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ describe('ipfs path', () => {
done()
})

it('isIPFS.urlOrPath should match an IANA-schema compliant ipfs url', (done) => {
const actual = isIPFS.urlOrPath('ipfs://QmYHNYAaYK5hm3ZhZFx5W9H6xydKDGimjdgJMrMSdnctEm')
expect(actual).to.equal(true)
done()
})

it('isIPFS.urlOrPath should match ipns url', (done) => {
const actual = isIPFS.urlOrPath('http://ipfs.io/ipns/foo.bar.com')
expect(actual).to.equal(true)
Expand Down
18 changes: 18 additions & 0 deletions test/test-url.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ describe('ipfs url', () => {
done()
})

it('isIPFS.ipfsUrl should match an IANA-schema compliant ipfs uri', (done) => {
const actual = isIPFS.ipfsUrl('ipfs://QmYHNYAaYK5hm3ZhZFx5W9H6xydKDGimjdgJMrMSdnctEm')
expect(actual).to.equal(true)
done()
})

it('isIPFS.ipfsUrl should match a complex ipfs url', (done) => {
const actual = isIPFS.ipfsUrl('http://ipfs.alexandria.media/ipfs/QmeWz9YZEeNFXQhHg4PnR5ZiNr5isttgi5n1tc1eD5EfGU/content/index.html?arg=val#hash')
expect(actual).to.equal(true)
Expand Down Expand Up @@ -72,12 +78,24 @@ describe('ipfs url', () => {
done()
})

it('isIPFS.ipnsUrl should not match an IANA-schema compliant ipfs uri', (done) => {
const actual = isIPFS.ipnsUrl('ipfs://QmYHNYAaYK5hm3ZhZFx5W9H6xydKDGimjdgJMrMSdnctEm')
expect(actual).to.equal(false)
done()
})

it('isIPFS.url should match an ipfs url', (done) => {
const actual = isIPFS.url('http://ipfs.io/ipfs/QmYHNYAaYK5hm3ZhZFx5W9H6xydKDGimjdgJMrMSdnctEm')
expect(actual).to.equal(true)
done()
})

it('isIPFS.url should match an IANA-schema compliant ipfs uri', (done) => {
const actual = isIPFS.url('ipfs://QmYHNYAaYK5hm3ZhZFx5W9H6xydKDGimjdgJMrMSdnctEm')
expect(actual).to.equal(true)
done()
})

it('isIPFS.url should match an ipns url', (done) => {
const actual = isIPFS.url('http://ipfs.io/ipns/github.com/')
expect(actual).to.equal(true)
Expand Down

0 comments on commit a5d55d9

Please sign in to comment.