-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
204 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Foundation | ||
import SharedModels | ||
|
||
extension Organizer { | ||
static let alice = Self( | ||
id: 1, | ||
name: "alice", | ||
imageName: "Alice", | ||
bio: "", | ||
links: [ | ||
Link( | ||
name: "@alice", | ||
url: URL(string: "https://example.com/alice")! | ||
) | ||
] | ||
) | ||
|
||
static let bob = Self( | ||
id: 2, | ||
name: "bob", | ||
imageName: "Bob", | ||
bio: "", | ||
links: [ | ||
Link( | ||
name: "@bob", | ||
url: URL(string: "https://example.com/bob")! | ||
) | ||
] | ||
) | ||
} |
143 changes: 143 additions & 0 deletions
143
MyLibrary/Tests/trySwiftFeatureTests/trySwiftTests.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import ComposableArchitecture | ||
import SharedModels | ||
import DependencyExtra | ||
import XCTest | ||
|
||
@testable import trySwiftFeature | ||
|
||
final class trySwiftTests: XCTestCase { | ||
@MainActor | ||
func testOrganizerTapped() async { | ||
let store = TestStore(initialState: TrySwift.State()) { | ||
TrySwift() | ||
} | ||
|
||
await store.send(\.view.organizerTapped) { | ||
$0.path[id: 0] = .organizers(.init()) | ||
} | ||
} | ||
|
||
@MainActor | ||
func testCodeOfConductTapped() async { | ||
let receivedUrl = ActorIsolated<URL?>(nil) | ||
|
||
let store = TestStore(initialState: TrySwift.State()) { | ||
TrySwift() | ||
} withDependencies: { | ||
$0.safari = { @Sendable in | ||
SafariEffect { url in | ||
await receivedUrl.withValue { | ||
$0 = url | ||
return true | ||
} | ||
} | ||
}() | ||
} | ||
|
||
await store.send(\.view.codeOfConductTapped) | ||
await receivedUrl.withValue { | ||
XCTAssertEqual($0, URL(string: "https://tryswift.jp/code-of-conduct_en")!) | ||
} | ||
} | ||
|
||
@MainActor | ||
func testPrivacyPolicyTapped() async { | ||
let receivedUrl = ActorIsolated<URL?>(nil) | ||
|
||
let store = TestStore(initialState: TrySwift.State()) { | ||
TrySwift() | ||
} withDependencies: { | ||
$0.safari = { @Sendable in | ||
SafariEffect { url in | ||
await receivedUrl.withValue { | ||
$0 = url | ||
return true | ||
} | ||
} | ||
}() | ||
} | ||
|
||
await store.send(\.view.privacyPolicyTapped) | ||
await receivedUrl.withValue { | ||
XCTAssertEqual($0, URL(string: "https://tryswift.jp/privacy-policy_en")!) | ||
} | ||
} | ||
|
||
@MainActor | ||
func testAcknowledgementsTapped() async { | ||
let store = TestStore(initialState: TrySwift.State()) { | ||
TrySwift() | ||
} | ||
|
||
await store.send(\.view.acknowledgementsTapped) { | ||
$0.path[id: 0] = .acknowledgements(.init()) | ||
} | ||
} | ||
|
||
@MainActor | ||
func testEventBriteTapped() async { | ||
let receivedUrl = ActorIsolated<URL?>(nil) | ||
|
||
let store = TestStore(initialState: TrySwift.State()) { | ||
TrySwift() | ||
} withDependencies: { | ||
$0.safari = { @Sendable in | ||
SafariEffect { url in | ||
await receivedUrl.withValue { | ||
$0 = url | ||
return true | ||
} | ||
} | ||
}() | ||
} | ||
|
||
await store.send(\.view.eventbriteTapped) | ||
await receivedUrl.withValue { | ||
XCTAssertEqual($0, URL(string: "https://www.eventbrite.com/e/try-swift-tokyo-2024-tickets-712565200697")!) | ||
} | ||
} | ||
|
||
@MainActor | ||
func testWebsiteTapped() async { | ||
let receivedUrl = ActorIsolated<URL?>(nil) | ||
|
||
let store = TestStore(initialState: TrySwift.State()) { | ||
TrySwift() | ||
} withDependencies: { | ||
$0.safari = { @Sendable in | ||
SafariEffect { url in | ||
await receivedUrl.withValue { | ||
$0 = url | ||
return true | ||
} | ||
} | ||
}() | ||
} | ||
|
||
await store.send(\.view.websiteTapped) | ||
await receivedUrl.withValue { | ||
XCTAssertEqual($0, URL(string: "https://tryswift.jp/_en")!) | ||
} | ||
} | ||
|
||
@MainActor | ||
func testProfileNavigation() async { | ||
let store = TestStore( | ||
initialState: TrySwift.State( | ||
path: StackState([ | ||
.organizers( | ||
Organizers.State( | ||
organizers: .init(arrayLiteral: .alice, .bob) | ||
) | ||
) | ||
]) | ||
) | ||
) { | ||
TrySwift() | ||
} | ||
|
||
await store.send(\.path[id: 0].organizers.delegate.organizerTapped, .alice) { | ||
$0.path[id: 1] = .profile(.init(organizer: .alice)) | ||
} | ||
} | ||
} |