diff --git a/src/find_closest_transmitter.js b/src/find_closest_transmitter.js index 82df0cf..2cdb1b5 100644 --- a/src/find_closest_transmitter.js +++ b/src/find_closest_transmitter.js @@ -13,7 +13,7 @@ const findClosestTransmitter = function (type, dataStore, path) { pathStr = parts.join('.'); if (pathStr.length === 0) { - throw new Error("Couldn't find " + type + " for " + pathStr); + throw new Error("Couldn't find " + type + " for " + path.join('.')); } } diff --git a/src/stakeout.js b/src/stakeout.js index 050ed1f..63ebaee 100644 --- a/src/stakeout.js +++ b/src/stakeout.js @@ -24,7 +24,9 @@ function notifyStakeouts(update, rootCursor) { if (path === '') { // This is a "set" call on the root cursor, so notify based on the properties of the new value - each(update.value, (v, key) => notifyStakeouts({ path: key, value: v }, rootCursor)); + each(update.value, (v, key) => { + notifyStakeouts({ path: [key], value: v, action: update.action }, rootCursor); + }); return; } diff --git a/test/state_trooper_test.js b/test/state_trooper_test.js index 92dade2..b7b0f75 100644 --- a/test/state_trooper_test.js +++ b/test/state_trooper_test.js @@ -107,6 +107,7 @@ describe('StateTrooper', function () { StateTrooper.stakeout('something.a', (cursor, update) => { result.push(update.value); + expect(update.path).to.be.an(Array); if (result.length === 3) { expect( result ).to.eql([4, 5, 6]) @@ -122,5 +123,23 @@ describe('StateTrooper', function () { cursor.refine('something.a').add(6); }); }); + + it('handles top-level set()', function (done) { + + StateTrooper.stakeout('something', (cursor, update) => { + expect(update.path).to.eql(['something']); + expect(update.value).to.have.key('b'); + expect(update.action).to.eql('set'); + done(); + }); + + go(function* () { + let cursor = yield take(cursorChan); + + cursor.set({ + something: { b: [1, 2, 3, 4] } + }); + }); + }); }); });