Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass file name to change event. #16

Merged
merged 1 commit into from Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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