Skip to content

Commit

Permalink
Cleanup shared
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgoedjen committed May 2, 2024
1 parent 7880303 commit 0d7854e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 43 deletions.
5 changes: 3 additions & 2 deletions Sources/Packages/Sources/WhiffFeatures/AppFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import TootSniffer

@ObservableState public struct State: Equatable, Sendable {
public let isExtension: Bool
public var loggedIn = false
@Shared public var loggedIn: Bool

@Presents public var export: ExportFeature.State?
@Presents public var authentication: AuthenticationFeature.State?

public init(isExtension: Bool) {
self.isExtension = isExtension
_loggedIn = Shared(false)
}

}
Expand Down Expand Up @@ -46,7 +47,7 @@ import TootSniffer
await dismissExtension(nil)
}
case .tappedAuthentication:
state.authentication = .init()
state.authentication = .init(loggedIn: state.$loggedIn)
return .none
case let .load(urls):
guard let url = urls.first else { return .none }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import AuthenticationServices

@ObservableState public struct State: Equatable, Sendable {

var loggedIn = false
@Shared var loggedIn: Bool
var domain: String = ""
var buttonDisabled = true

public init() {
public init(loggedIn: Shared<Bool>) {
_loggedIn = loggedIn
}

}
Expand Down
21 changes: 21 additions & 0 deletions Sources/Packages/Tests/WhiffFeaturesTests/AppFeatureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,25 @@ final class AppFeatureTests: XCTestCase {
}
}

func testDone() async throws {
let store = store = TestStore(
initialState: AppFeature.State(isExtension: true),
reducer: AppFeature()
.dependency(\.keyValueStorage, StubStorage())
.dependency(\.tootSniffer, StubTootSniffer(.success(.placeholder), .success(TootContext())))
.dependency(\.urlSession, .shared)
.dependency(\.dismissExtension) { error in
XCTAssertFalse(self.dismissCalled)
self.dismissCalled = true
self.dismissError = error
}
)

XCTAssertFalse(dismissCalled)
await store.send(.tappedDone)
await store.receive(.dismissed)
XCTAssertTrue(dismissCalled)
XCTAssertNil(dismissError)
}

}

This file was deleted.

0 comments on commit 0d7854e

Please sign in to comment.