Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw committed Aug 27, 2024
1 parent b5c3159 commit 3b8f235
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-case-paths",
"state" : {
"revision" : "71344dd930fde41e8f3adafe260adcbb2fc2a3dc",
"version" : "1.5.4"
"branch" : "add-wasm-ci",
"revision" : "e4430486fd74bddf5508f2b57558ff46d504429e"
}
},
{
Expand Down
20 changes: 10 additions & 10 deletions Tests/SwiftNavigationTests/IsolationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@

class IsolationTests: XCTestCase {
@MainActor
func testIsolationOnMinActor() async {
func testIsolationOnMainActor() async throws {
let model = MainActorModel()
let expectation = expectation(description: "observation")
expectation.expectedFulfillmentCount = 2
var didObserve = false
let token = SwiftNavigation.observe {
_ = model.count
MainActor.assertIsolated()
expectation.fulfill()
didObserve = true
}
model.count += 1
await fulfillment(of: [expectation], timeout: 1)
try await Task.sleep(for: .seconds(0.3))
XCTAssertEqual(didObserve, true)
_ = token
}

@GlobalActorIsolated
func testIsolationOnGlobalActor() async {
func testIsolationOnGlobalActor() async throws {
let model = GlobalActorModel()
let expectation = expectation(description: "observation")
expectation.expectedFulfillmentCount = 2
var didObserve = false
let token = SwiftNavigation.observe {
_ = model.count
GlobalActorIsolated.assertIsolated()
expectation.fulfill()
didObserve = true
}
model.count += 1
await fulfillment(of: [expectation], timeout: 1)
try await Task.sleep(for: .seconds(0.3))
XCTAssertEqual(didObserve, true)
_ = token
}
}
Expand Down
22 changes: 10 additions & 12 deletions Tests/SwiftNavigationTests/UITransactionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import XCTest

class UITransactionTests: XCTestCase {
@MainActor
func testTransactionKeyPropagates() async {
let expectation = expectation(description: "onChange")
expectation.expectedFulfillmentCount = 2

func testTransactionKeyPropagates() async throws {
let model = Model()
XCTAssertEqual(UITransaction.current.isSet, false)

var didObserve = true
observe {
if model.count == 0 {
XCTAssertEqual(UITransaction.current.isSet, false)
Expand All @@ -18,13 +16,14 @@ class UITransactionTests: XCTestCase {
} else {
XCTFail()
}
expectation.fulfill()
didObserve = true
}

withUITransaction(\.isSet, true) {
model.count += 1
}
await fulfillment(of: [expectation], timeout: 1)
try await Task.sleep(for: .seconds(0.3))
XCTAssertEqual(didObserve, true)
XCTAssertEqual(model.count, 1)
XCTAssertEqual(UITransaction.current.isSet, false)
}
Expand Down Expand Up @@ -88,14 +87,12 @@ class UITransactionTests: XCTestCase {
}

@MainActor
func testBindingTransactionKey() async {
let expectation = expectation(description: "onChange")
expectation.expectedFulfillmentCount = 2

func testBindingTransactionKey() async throws {
@UIBinding var count = 0
var transaction = UITransaction()
transaction.isSet = true

var didObserve = false
observe {
if count == 0 {
XCTAssertEqual(UITransaction.current.isSet, false)
Expand All @@ -104,13 +101,14 @@ class UITransactionTests: XCTestCase {
} else {
XCTFail()
}
expectation.fulfill()
didObserve = true
}

let bindingWithTransaction = $count.transaction(transaction)
bindingWithTransaction.wrappedValue = 1

await fulfillment(of: [expectation], timeout: 1)
try await Task.sleep(for: .seconds(0.3))
XCTAssertEqual(didObserve, true)
}
}

Expand Down

0 comments on commit 3b8f235

Please sign in to comment.