Skip to content

Commit 29a844b

Browse files
committed
pubkey#2471 multiple invocations of subscription after upsertLocal()
1 parent d0cea5b commit 29a844b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/unit/local-documents.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@ config.parallel('local-documents.test.js', () => {
114114
assert.strictEqual(doc.get('foo'), 'bar2');
115115
c.database.destroy();
116116
});
117+
it('should invoke subscription onces', async () => {
118+
let invocations = 0;
119+
const c = await humansCollection.create();
120+
const doc = await c.upsertLocal('foobar', {
121+
foo: 'bar',
122+
});
123+
const doc$ = doc.$.subscribe((doc) => {
124+
invocations++;
125+
});
126+
await c.upsertLocal('foobar', {
127+
foo: 'bar2',
128+
});
129+
doc$.unsubscribe();
130+
assert.strictEqual(invocations, 1);
131+
});
117132
});
118133
describe('negative', () => { });
119134
});

0 commit comments

Comments
 (0)