From a438ef263372e87726f99f3ec7a85a0b2342ecaf Mon Sep 17 00:00:00 2001 From: waidhoferj Date: Mon, 4 Apr 2022 15:06:41 -0700 Subject: [PATCH] added test --- tests/test_y_text.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_y_text.py b/tests/test_y_text.py index 8251a78..cd4278f 100644 --- a/tests/test_y_text.py +++ b/tests/test_y_text.py @@ -110,3 +110,29 @@ def callback(e): x.insert(txn, 1, "fgh") assert target == None assert delta == None + + +def test_drop_sub_id(): + d = Y.YDoc() + target = None + delta = None + + def callback(e): + nonlocal target + nonlocal delta + target = e.target + delta = e.delta + + x = d.get_text("test") + + def register_callback(x, callback): + # The subscription_id `i` is dropped here + i = x.observe(callback) + + register_callback(x, callback) + + with d.begin_transaction() as txn: + x.insert(txn, 0, "abcd") + + assert str(target) == str(x) + assert delta == [{"insert": "abcd"}]