This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
▿(.⅛,(.g,.g,.g)), ⩀(♪(.e,.½)), ▬(.⅛), | |
▿(.⅛,(.f,.f,.f)), ⩀(♪(♭.d,.½)), ▬(.⅛) | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
change(store, .by(.adding(.item(i))) ) | |
respond(.item(i, .wasAdded)) | |
expect(items(in: appState)).to(beEmpty()) | |
expect(dueDate(of:first(of:items(in: appState))!)).to(equal(Date.tomorrow.noon)) | |
expect(dueDate(of:first(of:appState.items)!)).to(equal(Date.tomorrow.noon)) | |
let newItem = change(item, .by(.updating(.completed(to: true)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
change(store, .by(.adding(.item(i))) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
respond(.item(i, .wasAdded)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect(items(in: appState)).to(beEmpty()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect(dueDate(of:first(of:items(in: appState))!)).to(equal(Date.tomorrow.noon)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect(dueDate(of:first(of:appState.items)!)).to(equal(Date.tomorrow.noon)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let newItem = change(item, .by(.updating(.completed(to: true)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func change(_ item: TodoItem, _ changes: TodoItem.Change...) -> TodoItem { item.alter(changes) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public | |
struct TodoItem: Identifiable, Hashable, Codable { | |
public enum Change: Equatable, Identifiable { | |
public var id: String { | |
switch self { | |
case .by(.updating(.completed(let b))): return "\(b)" | |
case .by(.updating(.dueDate (let d))): return d != nil ? "\(d!)" : "\(Date())" | |
case .by(.updating(.text (let t))): return t | |
case .by(.updating(.fork (let inner))): return inner.reduce("") { "\($0)\($1)" } | |
} |