Skip to content

Commit

Permalink
Pass file name to change event. (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jun 1, 2020
1 parent 27b1c19 commit 18e70f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -37,7 +37,7 @@ exports.create = function () {

Store.prototype.add = function (file) {
store[file.path] = file;
this.emit('change');
this.emit('change', file.path);
return this;
};

Expand Down
24 changes: 17 additions & 7 deletions test/index.js
Expand Up @@ -61,13 +61,23 @@ describe('mem-fs', function () {
assert.equal(this.store.add(coffeeFile), this.store);
});

it('triggers change event', function (done) {
this.store.on('change', function () {
var file = this.store.get('/test/file.coffee');
assert.equal(file.contents.toString(), 'test = 123');
done();
}.bind(this));
this.store.add(coffeeFile);
describe('change event', () => {
it('is triggered', function (done) {
this.store.on('change', function () {
var file = this.store.get('/test/file.coffee');
assert.equal(file.contents.toString(), 'test = 123');
done();
}.bind(this));
this.store.add(coffeeFile);
});

it('passes the file name to the listener', function (done) {
this.store.on('change', eventFile => {
assert.equal(eventFile, coffeeFile.path);
done();
});
this.store.add(coffeeFile);
});
});
});

Expand Down

0 comments on commit 18e70f0

Please sign in to comment.