Skip to content

Commit

Permalink
Fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoncal committed Dec 7, 2023
1 parent 65244eb commit a6b987b
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class WebhookResponseUpdateComplicationsTests: XCTestCase {
private var api: FakeHomeAssistantAPI!
private var webhookManager: FakeWebhookManager!
private var realm: Realm!
private var handler: WebhookResponseUpdateComplications?

override func setUpWithError() throws {
try super.setUpWithError()
Expand All @@ -25,6 +24,12 @@ class WebhookResponseUpdateComplicationsTests: XCTestCase {
FakeWatchComplication.rawRenderedUpdates = [:]
}

override func tearDown() {
api = nil
webhookManager = nil
realm = nil
}

func testNoComplicationGivesNoRequest() {
XCTAssertNil(WebhookResponseUpdateComplications.request(for: .init()))
}
Expand Down Expand Up @@ -127,8 +132,8 @@ class WebhookResponseUpdateComplicationsTests: XCTestCase {
realm.add(complications)
}

handler = WebhookResponseUpdateComplications(api: api)
handler?.watchComplicationClass = FakeWatchComplication.self
var handler = WebhookResponseUpdateComplications(api: api)
handler.watchComplicationClass = FakeWatchComplication.self

let request = WebhookResponseUpdateComplications.request(for: Set(complications))!
let result: [String: Any] = [
Expand All @@ -137,8 +142,6 @@ class WebhookResponseUpdateComplicationsTests: XCTestCase {
"c3|fwc3k1": 3,
]

guard let handler = handler else { return }

let expectation = self.expectation(description: "result")
handler.handle(request: .value(request), result: .value(result)).done { handlerResult in
XCTAssertNil(handlerResult.notification)
Expand Down

0 comments on commit a6b987b

Please sign in to comment.