feat: Adds view snapshot tests
This commit is contained in:
@@ -46,7 +46,7 @@ extension DatabaseClient.Projects: TestDependencyKey {
|
||||
{ trunk in
|
||||
trunk.with(
|
||||
\.$rooms,
|
||||
{
|
||||
{
|
||||
$0.with(\.$room)
|
||||
}
|
||||
)
|
||||
|
||||
22
Sources/HTMLSnapshotTesting/Snapshotting.swift
Normal file
22
Sources/HTMLSnapshotTesting/Snapshotting.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
import Elementary
|
||||
import SnapshotTesting
|
||||
|
||||
extension Snapshotting where Value == (any HTML), Format == String {
|
||||
public static var html: Snapshotting {
|
||||
var snapshotting = SimplySnapshotting.lines
|
||||
.pullback { (html: any HTML) in html.renderFormatted() }
|
||||
|
||||
snapshotting.pathExtension = "html"
|
||||
return snapshotting
|
||||
}
|
||||
}
|
||||
|
||||
extension Snapshotting where Value == String, Format == String {
|
||||
public static var html: Snapshotting {
|
||||
var snapshotting = SimplySnapshotting.lines
|
||||
.pullback { $0 }
|
||||
|
||||
snapshotting.pathExtension = "html"
|
||||
return snapshotting
|
||||
}
|
||||
}
|
||||
@@ -140,16 +140,22 @@ extension Project {
|
||||
#if DEBUG
|
||||
|
||||
extension Project {
|
||||
public static let mock = Self(
|
||||
id: UUID(0),
|
||||
name: "Testy McTestface",
|
||||
streetAddress: "1234 Sesame Street",
|
||||
city: "Monroe",
|
||||
state: "OH",
|
||||
zipCode: "55555",
|
||||
createdAt: Date(),
|
||||
updatedAt: Date()
|
||||
)
|
||||
|
||||
public static var mock: Self {
|
||||
@Dependency(\.uuid) var uuid
|
||||
@Dependency(\.date.now) var now
|
||||
|
||||
return .init(
|
||||
id: uuid(),
|
||||
name: "Testy McTestface",
|
||||
streetAddress: "1234 Sesame Street",
|
||||
city: "Monroe",
|
||||
state: "OH",
|
||||
zipCode: "55555",
|
||||
createdAt: now,
|
||||
updatedAt: now
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -65,3 +65,15 @@ extension User {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
||||
extension User {
|
||||
public static var mock: Self {
|
||||
@Dependency(\.uuid) var uuid
|
||||
@Dependency(\.date.now) var now
|
||||
return .init(id: uuid(), email: "testy@example.com", createdAt: now, updatedAt: now)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import Dependencies
|
||||
import Foundation
|
||||
|
||||
extension User {
|
||||
@@ -113,3 +114,27 @@ extension User.Profile {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
extension User.Profile {
|
||||
public static func mock(userID: User.ID) -> Self {
|
||||
@Dependency(\.uuid) var uuid
|
||||
@Dependency(\.date.now) var now
|
||||
|
||||
return .init(
|
||||
id: uuid(),
|
||||
userID: userID,
|
||||
firstName: "Testy",
|
||||
lastName: "McTestface",
|
||||
companyName: "Acme Co.",
|
||||
streetAddress: "1234 Sesame St",
|
||||
city: "Monroe",
|
||||
state: "OH",
|
||||
zipCode: "55555",
|
||||
createdAt: now,
|
||||
updatedAt: now
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user