Skip to content

Commit 05fc18e

Browse files
committed
Add test
1 parent 72b8bf3 commit 05fc18e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,6 @@ jupyter_ydoc/_version.py
147147
!.yarn/versions
148148
docs/source/api
149149
docs/source/changelog.md
150+
# pixi environments
151+
.pixi
152+

tests/test_ydocs.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from jupyter_ydoc import YBlob
2+
3+
4+
def test_yblob():
5+
yblob = YBlob()
6+
assert yblob.get() == b""
7+
yblob.set(b"012")
8+
assert yblob.get() == b"012"
9+
changes = []
10+
def callback(topic, event):
11+
print(topic, event)
12+
changes.append((topic, event))
13+
yblob.observe(callback)
14+
yblob.set(b"345")
15+
assert len(changes) == 1
16+
topic, event = changes[0]
17+
assert topic == "source"
18+
assert event.keys["bytes"]["oldValue"] == b"012"
19+
assert event.keys["bytes"]["newValue"] == b"345"

0 commit comments

Comments
 (0)