Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Jan 5, 2024
1 parent 72b8bf3 commit 09004e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@ jupyter_ydoc/_version.py
!.yarn/versions
docs/source/api
docs/source/changelog.md
# pixi environments
.pixi

21 changes: 21 additions & 0 deletions tests/test_ydocs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from jupyter_ydoc import YBlob


def test_yblob():
yblob = YBlob()
assert yblob.get() == b""
yblob.set(b"012")
assert yblob.get() == b"012"
changes = []

def callback(topic, event):
print(topic, event)
changes.append((topic, event))

yblob.observe(callback)
yblob.set(b"345")
assert len(changes) == 1
topic, event = changes[0]
assert topic == "source"
assert event.keys["bytes"]["oldValue"] == b"012"
assert event.keys["bytes"]["newValue"] == b"345"

0 comments on commit 09004e6

Please sign in to comment.