Skip to content

Commit 014e4b4

Browse files
committed
Add UndoManagerRegistration Tests
1 parent b2210cc commit 014e4b4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// UndoManagerRegistrationTests.swift
3+
// CodeEditTests
4+
//
5+
// Created by Khan Winter on 7/3/25.
6+
//
7+
8+
@testable import CodeEdit
9+
import Testing
10+
import Foundation
11+
import CodeEditTextView
12+
13+
@Suite
14+
struct UndoManagerRegistrationTests {
15+
let registrar = UndoManagerRegistration()
16+
let file = CEWorkspaceFile(url: URL(filePath: "/fake/dir/file.txt"))
17+
let textView = TextView(string: "hello world")
18+
19+
@Test
20+
func newUndoManager() {
21+
let manager = registrar.manager(forFile: file)
22+
#expect(manager.canUndo == false)
23+
}
24+
25+
@Test
26+
func undoManagersRetained() throws {
27+
let manager = registrar.manager(forFile: file)
28+
textView.setUndoManager(manager)
29+
manager.registerMutation(.init(insert: "hello", at: 0, limit: 11))
30+
31+
let sameManager = registrar.manager(forFile: file)
32+
#expect(manager === sameManager)
33+
#expect(sameManager.canUndo)
34+
}
35+
}

0 commit comments

Comments
 (0)