-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add backwards compatibility and more tests (#138)
* fix: backwards compatibility
- Loading branch information
1 parent
9220fda
commit 60e0da7
Showing
8 changed files
with
131 additions
and
77 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 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 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 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 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 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 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,52 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
chai.use(require('dirty-chai')) | ||
const expect = chai.expect | ||
const path = require('path') | ||
const rimraf = require('rimraf') | ||
if (!rimraf.sync) { | ||
// browser | ||
rimraf.sync = noop | ||
} | ||
const Repo = require('../') | ||
|
||
describe('IPFS Repo options Tests', () => { | ||
const repoPath = path.join(__dirname, 'slash', 'path') | ||
after(() => { | ||
rimraf.sync(repoPath) | ||
}) | ||
|
||
it('missing repoPath', () => { | ||
expect( | ||
() => new Repo() | ||
).to.throw('missing repoPath') | ||
}) | ||
|
||
it('default options', () => { | ||
const repo = new Repo(repoPath) | ||
expect(repo.options).to.deep.equal(expectedRepoOptions()) | ||
}) | ||
}) | ||
|
||
function noop () {} | ||
|
||
function expectedRepoOptions () { | ||
const options = { | ||
// packages are exchanged to browser-compatible | ||
// equivalents via package.browser. | ||
fs: require('datastore-fs'), | ||
level: require('leveldown'), | ||
lock: process.browser ? 'memory' : 'fs', | ||
sharding: !process.browser | ||
} | ||
|
||
if (process.browser) { | ||
options.fsOptions = { | ||
db: require('leveldown') | ||
} | ||
} | ||
|
||
return options | ||
} |
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