Files
GradientLoadingBar/Example/ExampleSnapshotTests/GradientLoadingBarController/GradientLoadingBarControllerTestCase.swift
T
2022-08-15 22:18:55 +02:00

55 lines
1.3 KiB
Swift

//
// GradientLoadingBarControllerTestCase.swift
// ExampleSnapshotTests
//
// Created by Felix Mau on 14.06.20.
// Copyright © 2020 Felix Mau. All rights reserved.
//
import SnapshotTesting
import XCTest
@testable import GradientLoadingBar
final class GradientLoadingBarControllerTestCase: XCTestCase {
// MARK: - Private properties
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()
window.rootViewController = rootViewController
let expectation = expectation(description: "Expect view to be completely fade in.")
// When
let gradientLoadingBarController = GradientLoadingBarController()
gradientLoadingBarController.fadeIn(duration: 0) { _ in
expectation.fulfill()
}
// Then
wait(for: [expectation], timeout: 0.1)
assertSnapshot(matching: window, as: .image)
}
}