-
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.
Merge pull request #219 from ipfs/feat-add-is-initialized-meethod
feat: add isInitialized method
- Loading branch information
Showing
5 changed files
with
71 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* eslint max-nested-callbacks: ["error", 8] */ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
chai.use(require('dirty-chai')) | ||
const expect = chai.expect | ||
const os = require('os') | ||
const path = require('path') | ||
const IPFSRepo = require('../src') | ||
|
||
describe('isInitialized', () => { | ||
let repo | ||
|
||
beforeEach(() => { | ||
const repoPath = path.join(os.tmpdir(), 'test-repo-for-' + Math.random()) | ||
repo = new IPFSRepo(repoPath) | ||
}) | ||
|
||
it('should be false before initialization', async () => { | ||
expect(await repo.isInitialized()).to.be.false() | ||
}) | ||
|
||
it('should be true after initialization', async () => { | ||
await repo.init({}) | ||
expect(await repo.isInitialized()).to.be.true() | ||
}) | ||
|
||
it('should be true after initialization and opening', async () => { | ||
await repo.init({}) | ||
await repo.open() | ||
expect(await repo.isInitialized()).to.be.true() | ||
}) | ||
|
||
it('should be true after initialization, opening and closing', async () => { | ||
await repo.init({}) | ||
await repo.open() | ||
await repo.close() | ||
expect(await repo.isInitialized()).to.be.true() | ||
}) | ||
}) |
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