-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
123 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var chai_1 = require("chai"); | ||
var util_1 = require("./util"); | ||
describe('exists(path, callback)', function () { | ||
var vol = util_1.create(); | ||
it('Returns true if file exists', function (done) { | ||
vol.exists('/foo', function (exists) { | ||
chai_1.expect(exists).to.be.true; | ||
done(); | ||
}); | ||
}); | ||
it('Returns false if file does not exist', function (done) { | ||
vol.exists('/foo2', function (exists) { | ||
chai_1.expect(exists).to.be.false; | ||
done(); | ||
}); | ||
}); | ||
it('Throws correct error if callback not provided', function (done) { | ||
try { | ||
vol.exists('/foo', undefined); | ||
throw new Error('not_this'); | ||
} | ||
catch (err) { | ||
chai_1.expect(err.message).to.equal('callback must be a function'); | ||
done(); | ||
} | ||
}); | ||
it('invalid path type should throw', function () { | ||
try { | ||
vol.exists(123, function () { }); | ||
throw new Error('not_this'); | ||
} | ||
catch (err) { | ||
chai_1.expect(err.message !== 'not_this').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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var chai_1 = require("chai"); | ||
var util_1 = require("./util"); | ||
describe('existsSync(path)', function () { | ||
var vol = util_1.create(); | ||
it('Returns true if file exists', function () { | ||
var result = vol.existsSync('/foo'); | ||
chai_1.expect(result).to.be.true; | ||
}); | ||
it('Returns false if file does not exist', function () { | ||
var result = vol.existsSync('/foo2'); | ||
chai_1.expect(result).to.be.false; | ||
}); | ||
it('invalid path type should not throw', function () { | ||
chai_1.expect(vol.existsSync(123)).to.be.false; | ||
}); | ||
}); |
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,36 @@ | ||
import {expect} from 'chai'; | ||
import {create} from "./util"; | ||
|
||
|
||
describe('exists(path, callback)', () => { | ||
const vol = create(); | ||
it('Returns true if file exists', done => { | ||
vol.exists('/foo', exists => { | ||
expect(exists).to.be.true; | ||
done(); | ||
}); | ||
}); | ||
it('Returns false if file does not exist', done => { | ||
vol.exists('/foo2', exists => { | ||
expect(exists).to.be.false; | ||
done(); | ||
}); | ||
}); | ||
it('Throws correct error if callback not provided', done => { | ||
try { | ||
vol.exists('/foo', undefined); | ||
throw new Error('not_this'); | ||
} catch(err) { | ||
expect(err.message).to.equal('callback must be a function'); | ||
done(); | ||
} | ||
}); | ||
it('invalid path type should throw', () => { | ||
try { | ||
vol.exists(123 as any, () => {}); | ||
throw new Error('not_this'); | ||
} catch(err) { | ||
expect(err.message !== 'not_this').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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {expect} from 'chai'; | ||
import {create} from "./util"; | ||
|
||
|
||
describe('existsSync(path)', () => { | ||
const vol = create(); | ||
it('Returns true if file exists', () => { | ||
const result = vol.existsSync('/foo'); | ||
expect(result).to.be.true; | ||
}); | ||
it('Returns false if file does not exist', () => { | ||
const result = vol.existsSync('/foo2'); | ||
expect(result).to.be.false; | ||
}); | ||
it('invalid path type should not throw', () => { | ||
expect(vol.existsSync(123 as any)).to.be.false; | ||
}); | ||
}); |
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