-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
1 parent
57f3e38
commit b63aaff
Showing
5 changed files
with
78 additions
and
97 deletions.
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
74 changes: 74 additions & 0 deletions
74
Tests/SpeziTests/StandardTests/StandardConstraintTests.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,74 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
@testable import Spezi | ||
import SwiftUI | ||
import XCTest | ||
import XCTRuntimeAssertions | ||
|
||
|
||
private protocol ExampleConstraint: Standard { | ||
func betterFulfill(expectation: XCTestExpectation) | ||
} | ||
|
||
|
||
extension MockStandard: ExampleConstraint { | ||
func betterFulfill(expectation: XCTestExpectation) { | ||
fulfill(expectation: expectation) | ||
} | ||
} | ||
|
||
|
||
final class StandardConstraintTests: XCTestCase { | ||
final class StandardConstraintTestComponent: Component { | ||
@StandardActor private var standard: any ExampleConstraint | ||
|
||
let expectation: XCTestExpectation | ||
|
||
|
||
init(expectation: XCTestExpectation) { | ||
self.expectation = expectation | ||
} | ||
|
||
|
||
func configure() { | ||
Task { | ||
await standard.betterFulfill(expectation: expectation) | ||
} | ||
} | ||
} | ||
|
||
class StandardConstraintTestApplicationDelegate: SpeziAppDelegate { | ||
Check failure on line 46 in Tests/SpeziTests/StandardTests/StandardConstraintTests.swift GitHub Actions / SwiftLint / SwiftLint / SwiftLint
|
||
let expectation: XCTestExpectation | ||
|
||
|
||
override var configuration: Configuration { | ||
Configuration(standard: MockStandard()) { | ||
StandardConstraintTestComponent(expectation: expectation) | ||
} | ||
} | ||
|
||
|
||
init(expectation: XCTestExpectation) { | ||
self.expectation = expectation | ||
} | ||
} | ||
|
||
|
||
func testStandardConstraint() async throws { | ||
let expectation = XCTestExpectation(description: "Component") | ||
expectation.assertForOverFulfill = true | ||
|
||
let standardConstraintTestApplicationDelegate = await StandardConstraintTestApplicationDelegate( | ||
Check failure on line 67 in Tests/SpeziTests/StandardTests/StandardConstraintTests.swift GitHub Actions / SwiftLint / SwiftLint / SwiftLint
|
||
expectation: expectation | ||
) | ||
_ = await standardConstraintTestApplicationDelegate.spezi | ||
|
||
await fulfillment(of: [expectation], timeout: 0.01) | ||
} | ||
} |
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