mirror of https://github.com/seald/nedb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
946 B
36 lines
946 B
11 years ago
|
var should = require('chai').should()
|
||
|
, assert = require('chai').assert
|
||
|
, customUtils = require('../lib/customUtils')
|
||
|
, fs = require('fs')
|
||
|
;
|
||
|
|
||
|
|
||
|
describe('customUtils', function () {
|
||
|
|
||
|
describe('ensureFileDoesntExist', function () {
|
||
|
|
||
|
it('Doesnt do anything if file already doesnt exist', function (done) {
|
||
|
customUtils.ensureFileDoesntExist('workspace/nonexisting', function (err) {
|
||
|
assert.isNull(err);
|
||
|
fs.existsSync('workspace/nonexisting').should.equal(false);
|
||
|
done();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it('Deletes file if it exists', function (done) {
|
||
|
fs.writeFileSync('workspace/existing', 'hello world', 'utf8');
|
||
|
fs.existsSync('workspace/existing').should.equal(true);
|
||
|
|
||
|
customUtils.ensureFileDoesntExist('workspace/existing', function (err) {
|
||
|
assert.isNull(err);
|
||
|
fs.existsSync('workspace/existing').should.equal(false);
|
||
|
done();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
});
|