Skip to content

Commit

Permalink
Ben's feedback; config updated -> set
Browse files Browse the repository at this point in the history
  • Loading branch information
jwolski committed Aug 28, 2015
1 parent 1ba4fc9 commit 4d8c899
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Config.prototype.get = function get(key) {
Config.prototype.set = function set(key, value) {
var oldValue = this.store[key];
this.store[key] = value;
this.emit('changed', key, value, oldValue);
this.emit('changed.' + key, value, oldValue);
this.emit('set', key, value, oldValue);
this.emit('set.' + key, value, oldValue);
};

Config.prototype._seed = function _seed(seed) {
Expand Down
16 changes: 6 additions & 10 deletions test/unit/config_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,17 @@ test('changed events', function t(assert) {
assert.plan(2);

var config = new Config();
config.on('changed', onConfigChanged);
config.on('set', function onSet() {
assert.pass('set');
});
var configKey = 'somekey';
config.on('changed.' + configKey, onConfigKeyChanged);
config.on('set.' + configKey, function onKeySet() {
assert.pass('key set');
});
var configVal = 'someval';
config.set(configKey, configVal); // this triggers change events *fingers crossed*

assert.end();

function onConfigChanged() {
assert.pass('changed');
}

function onConfigKeyChanged() {
assert.pass('key changed');
}
});

test('seeds known config', function t(assert) {
Expand Down

0 comments on commit 4d8c899

Please sign in to comment.