mirror of
https://github.com/fxm90/GradientLoadingBar.git
synced 2026-06-16 12:24:31 +00:00
♻️ :: Fix snapshot tests
This commit is contained in:
+25
-8
@@ -13,25 +13,42 @@ import XCTest
|
||||
|
||||
final class GradientLoadingBarControllerTestCase: XCTestCase {
|
||||
|
||||
// MARK: - Config
|
||||
// MARK: - Private properties
|
||||
|
||||
private enum Config {
|
||||
/// The percentage of pixels that must match.
|
||||
static let precision: Float = 0.99
|
||||
private var window: UIWindow!
|
||||
|
||||
// MARK: - Public methods
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
window = UIApplication.shared.keyWindowInConnectedScenes
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
window = nil
|
||||
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
// MARK: - Test cases
|
||||
|
||||
func test_gradientLoadingBarController() {
|
||||
// Given
|
||||
// Show an empty view controller behind loading bar in our test.
|
||||
let rootViewController = UIViewController()
|
||||
let gradientLoadingBarController = GradientLoadingBarController()
|
||||
window.rootViewController = rootViewController
|
||||
|
||||
let expectation = expectation(description: "Expect view to be completely fade in.")
|
||||
|
||||
// When
|
||||
gradientLoadingBarController.fadeIn(duration: 0)
|
||||
let gradientLoadingBarController = GradientLoadingBarController()
|
||||
gradientLoadingBarController.fadeIn(duration: 0) { _ in
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
// Then
|
||||
assertSnapshot(matching: rootViewController,
|
||||
as: .image(drawHierarchyInKeyWindow: true, precision: Config.precision))
|
||||
wait(for: [expectation], timeout: 0.1)
|
||||
assertSnapshot(matching: window, as: .image)
|
||||
}
|
||||
}
|
||||
|
||||
+25
-8
@@ -14,25 +14,42 @@ import XCTest
|
||||
final class NotchGradientLoadingBarControllerTestCase: XCTestCase {
|
||||
// swiftlint:disable:previous type_name
|
||||
|
||||
// MARK: - Config
|
||||
// MARK: - Private properties
|
||||
|
||||
private enum Config {
|
||||
/// The percentage of pixels that must match.
|
||||
static let precision: Float = 0.99
|
||||
private var window: UIWindow!
|
||||
|
||||
// MARK: - Public methods
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
window = UIApplication.shared.keyWindowInConnectedScenes
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
window = nil
|
||||
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
// MARK: - Test cases
|
||||
|
||||
func test_notchGradientLoadingBarController() {
|
||||
// Given
|
||||
// Show an empty view controller behind loading bar in our test.
|
||||
let rootViewController = UIViewController()
|
||||
let notchGradientLoadingBarController = NotchGradientLoadingBarController()
|
||||
window.rootViewController = rootViewController
|
||||
|
||||
let expectation = expectation(description: "Expect view to be completely fade in.")
|
||||
|
||||
// When
|
||||
notchGradientLoadingBarController.fadeIn(duration: 0)
|
||||
let gradientLoadingBarController = NotchGradientLoadingBarController()
|
||||
gradientLoadingBarController.fadeIn(duration: 0) { _ in
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
// Then
|
||||
assertSnapshot(matching: rootViewController,
|
||||
as: .image(drawHierarchyInKeyWindow: true, precision: Config.precision))
|
||||
wait(for: [expectation], timeout: 0.1)
|
||||
assertSnapshot(matching: window, as: .image)
|
||||
}
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 69 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 75 KiB |
Reference in New Issue
Block a user