Skip to content

Commit

Permalink
Merge pull request #27 from BigstickCarpet/init_tests
Browse files Browse the repository at this point in the history
Fixes Issue #23
  • Loading branch information
JamesMessinger authored Oct 26, 2016
2 parents 6e6b88f + 2ebc9f8 commit ab3744f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ Assert that _both_ paths exist, are files, contain the same content, and have th
* creation time (`stats.birthtime`)
* last-modified time (`stats.mtime`)
* last-changed time (`stats.ctime`)
* last-access time (`stats.atime`)


expect(path).to.be.a.file(?msg).and.deep.equal(otherPath, ?msg);
Expand All @@ -356,6 +355,7 @@ Assert that _both_ paths exist, are files, contain the same content, and have th

* Reads both files as utf8 text (could update to support base64, binary Buffer etc).
* To negate this using `expect/should` you chain the `.not`-negation ***after*** the regular `file()`.
* last-access time (`stats.atime`) is _not_ included in the comparison, since just reading this value (via `fs.stat()`) causes it to change on some operating systems, which could result in unstable tests

### file().with.json

Expand Down
1 change: 0 additions & 1 deletion lib/assertions/file_equal.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ module.exports = function (chai, utils) {
var comparisons = [
{prop: 'uid', name: 'owner'},
{prop: 'gid', name: 'group id'},
{prop: 'atime', name: 'last-access time'},
{prop: 'mtime', name: 'last-modified time'},
{prop: 'ctime', name: 'last-changed time'},
{prop: 'birthtime', name: 'creation time'},
Expand Down
26 changes: 13 additions & 13 deletions test/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ var assert = chai.assert;
// import assertion multi tester
require('./tester')(chai, _);

before(function () {
// create some empty dirs (cannot check-in empty dirs to git)
mkdirp.sync('./test/tmp');
mkdirp.sync('./test/fixtures/empty');
mkdirp.sync('./test/fixtures/dir/.dotdir/empty');
mkdirp.sync('./test/fixtures/dir-copy/.dotdir/empty');
// create some empty dirs (cannot check-in empty dirs to git)
mkdirp.sync('./test/tmp');
mkdirp.sync('./test/fixtures/empty');
mkdirp.sync('./test/fixtures/dir/.dotdir/empty');
mkdirp.sync('./test/fixtures/dir-copy/.dotdir/empty');

// change the times of alpha-copy.txt, so it will be equal, but not DEEP equal to alpha.txt
touch.sync('./test/fixtures/alpha-copy.txt', {time: '2016-01-01T00:00:00Z'});

// delete files that get created automatically by the OS (they mess-up directory listings)
del.sync('test/fixtures/**/.DS_Store', {dot: true});
del.sync('test/fixtures/**/Thumbs.db', {dot: true});

describe('initialized', function () {
assert.isDirectory('./test/tmp');
assert.isDirectory('./test/fixtures');
assert.isDirectory('./test/fixtures/empty');
assert.isDirectory('./test/fixtures/dir/.dotdir/empty');
assert.isDirectory('./test/fixtures/dir-copy/.dotdir/empty');

// change the times of alpha-copy.txt, so it will be equal, but not DEEP equal to alpha.txt
touch.sync('./test/fixtures/alpha-copy.txt', {time: '2016-01-01T00:00:00Z'});

// delete files that get created automatically by the OS (they mess-up directory listings)
del.sync('test/fixtures/**/.DS_Store', {dot: true});
del.sync('test/fixtures/**/Thumbs.db', {dot: true});
});

describe('chai-fs', function () {
Expand Down

0 comments on commit ab3744f

Please sign in to comment.