Skip to content

Commit

Permalink
fixed UndoManager tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Horusiath committed Mar 4, 2024
1 parent a7f9834 commit 62f2574
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Tests/YSwiftTests/YUndoManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,22 @@ class YUndoManagerTests: XCTestCase {
let localOrigin = Origin("local")

let remoteDocument = YDocument()
let remoteText = document.getOrCreateText(named: "test")
let remoteText = remoteDocument.getOrCreateText(named: "test")
manager.addOrigin(localOrigin) // only track transaction from local origin

// create some changes locally
document.transactSync(origin: localOrigin) { txn in
self.text.insert("hello", at: 0, in: txn)
self.manager.wrap() // add changes on a stack: they will be undone as one
}
self.manager.wrap() // add changes on a stack: they will be undone as one

exchangeUpdates(document, remoteDocument)

// concurrent change on the remote replica
document.transactSync(origin: localOrigin) { txn in
self.text.insert(" world", at: 5, in: txn)
}
self.manager.wrap() // add next batch of changes on a stack
remoteText.insert("<break>", at: 1)

XCTAssertEqual(text.getString(), "hello world")
Expand Down

0 comments on commit 62f2574

Please sign in to comment.