File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed
CodeEditTests/Features/Welcome
CodeEdit/Features/Documents/Controllers Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ final class CodeEditDocumentController: NSDocumentController {
6868 print ( " Unable to open document ' \( url) ': \( errorMessage) " )
6969 }
7070
71- RecentProjectsStore . documentOpened ( at: url)
71+ RecentProjectsStore . default . documentOpened ( at: url)
7272 completionHandler ( document, documentWasAlreadyOpen, error)
7373 }
7474 }
Original file line number Diff line number Diff line change 1+ //
2+ // RecentProjectsTests.swift
3+ // CodeEditTests
4+ //
5+ // Created by Khan Winter on 5/27/25.
6+ //
7+
8+ import Testing
9+ import Foundation
10+ @testable import CodeEdit
11+
12+ class RecentProjectsTests {
13+ let store : RecentProjectsStore
14+
15+ init ( ) {
16+ let defaults = UserDefaults ( suiteName: #file) !
17+ store = RecentProjectsStore ( defaults: defaults)
18+ }
19+
20+ deinit {
21+ try ? FileManager . default. removeItem ( atPath: #file + " .plist " )
22+ }
23+
24+ @Test
25+ func newStoreEmpty( ) {
26+ #expect( store. recentURLs ( ) . isEmpty)
27+ }
28+
29+ @Test
30+ func savesURLs( ) {
31+ store. documentOpened ( at: URL ( filePath: " Directory/ " , directoryHint: . isDirectory) )
32+ store. documentOpened ( at: URL ( filePath: " Directory/file.txt " , directoryHint: . notDirectory) )
33+
34+ #expect( store. recentURLs ( ) . count == 2 )
35+ }
36+
37+ @Test
38+ func maxesOutAt100Items( ) {
39+ for idx in 0 ..< 200 {
40+ store. documentOpened (
41+ at: URL (
42+ filePath: " file \( idx) .txt " ,
43+ directoryHint: Bool . random ( ) ? . isDirectory : . notDirectory
44+ )
45+ )
46+ }
47+
48+ #expect( store. recentURLs ( ) . count == 100 )
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments