Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Apr 9, 2024
1 parent 9af2a17 commit f68c1cd
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Tests/ChangelogFeatureTests/ChangelogFeatureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import XCTest
@testable import ChangelogFeature
@testable import UserDefaultsClient

@MainActor
class ChangelogFeatureTests: XCTestCase {
@MainActor
func testOnAppear_IsUpToDate() async {
let changelog = Changelog(
changes: [
Expand Down Expand Up @@ -45,6 +45,7 @@ class ChangelogFeatureTests: XCTestCase {
}
}

@MainActor
func testOnAppear_IsUpBehind() async {
let changelog = Changelog(
changes: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import SharedModels
import SiteMiddleware
import XCTest

@MainActor
class GameOverFeatureIntegrationTests: XCTestCase {
@MainActor
func testSubmitSoloScore() async {
await withMainSerialExecutor {
let ranks: [TimeScope: LeaderboardScoreResult.Rank] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import XCTest

@testable import LeaderboardFeature

@MainActor
class LeaderboardFeatureIntegrationTests: XCTestCase {
@MainActor
func testSoloIntegrationWithLeaderboardResults() async {
await withMainSerialExecutor {
let fetchLeaderboardsEntries = [
Expand Down Expand Up @@ -59,6 +59,7 @@ class LeaderboardFeatureIntegrationTests: XCTestCase {
}
}

@MainActor
func testVocabIntegrationWithLeaderboardResults() async {
let fetchVocabEntries = [
FetchVocabLeaderboardResponse.Entry.init(
Expand Down
5 changes: 3 additions & 2 deletions Tests/LeaderboardFeatureTests/LeaderboardFeatureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import XCTest
@testable import LeaderboardFeature
@testable import SharedModels

@MainActor
class LeaderboardFeatureTests: XCTestCase {
@MainActor
func testScopeSwitcher() async {
let store = TestStore(initialState: Leaderboard.State()) {
Leaderboard()
Expand All @@ -24,6 +24,7 @@ class LeaderboardFeatureTests: XCTestCase {
}
}

@MainActor
func testTimeScopeSynchronization() async {
let store = TestStore(initialState: Leaderboard.State()) {
Leaderboard()
Expand All @@ -49,6 +50,7 @@ class LeaderboardFeatureTests: XCTestCase {
await task2.cancel()
}

@MainActor
func testCubePreview() async {
let wordId = Word.Id(rawValue: UUID(uuidString: "00000000-0000-0000-0000-00000000304d")!)
let vocabEntry = FetchVocabLeaderboardResponse.Entry(
Expand Down Expand Up @@ -104,7 +106,6 @@ class LeaderboardFeatureTests: XCTestCase {
$0.mainQueue = .immediate
}


await store.send(.vocab(.task)) {
$0.vocab.isLoading = true
$0.vocab.resultEnvelope = .placeholder
Expand Down
5 changes: 4 additions & 1 deletion Tests/LeaderboardFeatureTests/LeaderboardResultsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import XCTest

@testable import LeaderboardFeature

@MainActor
class LeaderboardTests: XCTestCase {
@MainActor
func testOnAppear() async {
let store = TestStore(
initialState: LeaderboardResults.State(timeScope: TimeScope.lastWeek)
Expand All @@ -28,6 +28,7 @@ class LeaderboardTests: XCTestCase {
}
}

@MainActor
func testChangeGameMode() async {
let store = TestStore(
initialState: LeaderboardResults.State(timeScope: TimeScope.lastWeek)
Expand All @@ -45,6 +46,7 @@ class LeaderboardTests: XCTestCase {
}
}

@MainActor
func testChangeTimeScope() async {
let store = TestStore(
initialState: LeaderboardResults.State(timeScope: TimeScope.lastWeek)
Expand All @@ -66,6 +68,7 @@ class LeaderboardTests: XCTestCase {
}
}

@MainActor
func testUnhappyPath() async {
let store = TestStore(
initialState: LeaderboardResults<TimeScope>.State(timeScope: .lastWeek)
Expand Down
4 changes: 3 additions & 1 deletion Tests/MultiplayerFeatureTests/MultiplayerFeatureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import MultiplayerFeature

@MainActor
class MultiplayerFeatureTests: XCTestCase {
@MainActor
func testStartGame_GameCenterAuthenticated() async {
let didPresentMatchmakerViewController = ActorIsolated(false)
let store = TestStore(initialState: Multiplayer.State(hasPastGames: false)) {
Expand All @@ -20,6 +20,7 @@ class MultiplayerFeatureTests: XCTestCase {
await didPresentMatchmakerViewController.withValue { XCTAssertTrue($0) }
}

@MainActor
func testStartGame_GameCenterNotAuthenticated() async {
let didPresentAuthentication = ActorIsolated(false)
let store = TestStore(
Expand All @@ -37,6 +38,7 @@ class MultiplayerFeatureTests: XCTestCase {
await didPresentAuthentication.withValue { XCTAssertTrue($0) }
}

@MainActor
func testNavigateToPastGames() async {
let store = TestStore(
initialState: Multiplayer.State(hasPastGames: true)
Expand Down
5 changes: 4 additions & 1 deletion Tests/MultiplayerFeatureTests/PastGamesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import XCTest

@testable import MultiplayerFeature

@MainActor
class PastGamesTests: XCTestCase {
@MainActor
func testLoadMatches() async {
let store = TestStore(initialState: PastGames.State()) {
PastGames()
Expand All @@ -24,6 +24,7 @@ class PastGamesTests: XCTestCase {
}
}

@MainActor
func testOpenMatch() async {
let store = TestStore(initialState: PastGames.State(pastGames: [pastGameState])) {
PastGames()
Expand All @@ -36,6 +37,7 @@ class PastGamesTests: XCTestCase {
await store.receive(\.pastGames[id: "id"].delegate.openMatch)
}

@MainActor
func testRematch() async {
let store = TestStore(initialState: PastGames.State(pastGames: [pastGameState])) {
PastGames()
Expand All @@ -58,6 +60,7 @@ class PastGamesTests: XCTestCase {
await store.receive(\.pastGames[id: "id"].delegate.openMatch)
}

@MainActor
func testRematch_Failure() async {
struct RematchFailure: Error, Equatable {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import XCTest

@testable import ServerConfigClient

@MainActor
class UpgradeInterstitialFeatureTests: XCTestCase {
let scheduler = RunLoop.test

@MainActor
func testUpgrade() async {
await withMainSerialExecutor {
let dismissed = LockIsolated(false)
Expand Down Expand Up @@ -47,7 +47,10 @@ class UpgradeInterstitialFeatureTests: XCTestCase {
$0.dismiss = .init { dismissed.setValue(true) }
$0.mainRunLoop = .immediate
$0.serverConfig.config = { .init() }
$0.storeKit.addPayment = { await paymentAdded.setValue($0.productIdentifier) }
$0.storeKit.addPayment = {
let productIdentifier = $0.productIdentifier
await paymentAdded.setValue(productIdentifier)
}
$0.storeKit.observer = { observer.stream }
$0.storeKit.fetchProducts = { _ in
.init(
Expand Down Expand Up @@ -84,6 +87,7 @@ class UpgradeInterstitialFeatureTests: XCTestCase {
}
}

@MainActor
func testWaitAndDismiss() async {
let dismissed = LockIsolated(false)
let store = TestStore(
Expand Down Expand Up @@ -122,6 +126,7 @@ class UpgradeInterstitialFeatureTests: XCTestCase {
XCTAssert(dismissed.value)
}

@MainActor
func testMaybeLater_Dismissable() async {
let dismissed = LockIsolated(false)
let store = TestStore(
Expand Down

0 comments on commit f68c1cd

Please sign in to comment.