1
0
mirror of git://jb55.com/damus synced 2024-09-16 02:03:45 +00:00
damus/damusTests/EventViewTests.swift
Daniel D’Aquino 3b76fcb743 test: Add basic snapshot test coverage for EventView
This commit adds a basic snapshot test for EventView, and also adds some testing infrastructure to help with mocking NostrDB behavior.

Test
----

PASS

Device: iOS 17.0 Simulator
iOS: 17.0
Damus: This commit
Steps: Run `EventViewTests`
Results: Snapshot matches baseline reference added
2023-10-16 03:13:28 +02:00

47 lines
1.7 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// EventViewTests.swift
// damusTests
//
// Created by Daniel DAquino on 2023-10-13.
//
import Foundation
import XCTest
import SnapshotTesting
import SwiftUI
@testable import damus
final class EventViewTests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testBasicEventViewLayout() {
let test_mock_damus_state = generate_test_damus_state(
mock_profile_info: [
// Manually mock some profile info so that we have a more realistic-looking note
jack_keypair.pubkey: Profile(
name: "jack",
display_name: "Jack Dorsey"
)
]
)
let test_note = NostrEvent(
content: "Nostr is the super app. Because its actually an ecosystem of apps, all of which make each other better. People havent grasped that yet. They will when its more accessible and onboarding is more straightforward and intuitive.",
keypair: jack_keypair,
createdAt: UInt32(Date.init(timeIntervalSinceNow: -60).timeIntervalSince1970)
)!
let eventViewTest = EventView(damus: test_mock_damus_state, event: test_note).padding()
let hostView = UIHostingController(rootView: eventViewTest)
// Run snapshot check
assertSnapshot(matching: hostView, as: .image(on: .iPhone13(.portrait)))
}
}