-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from rcaos/snapshot-tests
Fix Snapshot tests
- Loading branch information
Showing
182 changed files
with
1,661 additions
and
861 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
21 changes: 21 additions & 0 deletions
21
Projects/Features/Account/Tests/Account/Presentation/AccountViewControllerFactoryMock.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,21 @@ | ||
// | ||
// AccountViewControllerFactoryMock.swift | ||
// AccountTests | ||
// | ||
// Created by Jeans Ruiz on 20/12/21. | ||
// | ||
|
||
import UIKit | ||
@testable import Account | ||
|
||
class AccountViewControllerFactoryMock: AccountViewControllerFactory { | ||
func makeSignInViewController() -> UIViewController { | ||
let viewModel = SignInViewModelMock(state: .initial) | ||
return SignInViewController(viewModel: viewModel) | ||
} | ||
|
||
func makeProfileViewController(with account: AccountResult) -> UIViewController { | ||
let viewModel = ProfileViewModelMock(account: account) | ||
return ProfileViewController(viewModel: viewModel) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Projects/Features/Account/Tests/Account/Presentation/AccountViewDarkTests.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,44 @@ | ||
// | ||
// AccountViewDarkTests.swift | ||
// AccountTests | ||
// | ||
// Created by Jeans Ruiz on 20/12/21. | ||
// | ||
|
||
import XCTest | ||
import SnapshotTesting | ||
import RxSwift | ||
|
||
@testable import Account | ||
|
||
class AccountViewDarkTests: XCTestCase { | ||
|
||
private let factory = AccountViewControllerFactoryMock() | ||
|
||
override func setUp() { | ||
super.setUp() | ||
isRecording = false | ||
} | ||
|
||
func test_WhenViewIsLogin_thenShowLoginScreen() { | ||
// given | ||
let accountViewModel = AccountViewModelMock(state: .login) | ||
|
||
let viewController = AccountViewController(viewModel: accountViewModel, viewControllersFactory: factory) | ||
viewController.overrideUserInterfaceStyle = .dark | ||
|
||
// then | ||
assertSnapshot(matching: viewController, as: .wait(for: 1, on: .image(on: .iPhoneSe))) | ||
} | ||
|
||
func test_WhenViewIsLogged_thenShowProfileScreen() { | ||
// given | ||
let accountViewModel = AccountViewModelMock(state: .profile(account: AccountResult.stub())) | ||
|
||
let viewController = AccountViewController(viewModel: accountViewModel, viewControllersFactory: factory) | ||
viewController.overrideUserInterfaceStyle = .dark | ||
|
||
// then | ||
assertSnapshot(matching: viewController, as: .wait(for: 1, on: .image(on: .iPhoneSe))) | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
Projects/Features/Account/Tests/Account/Presentation/AccountViewLightTests.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,45 @@ | ||
// | ||
// AccountViewLightTests.swift | ||
// AccountTV | ||
// | ||
// Created by Jeans Ruiz on 6/19/20. | ||
// Copyright © 2020 Jeans. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
import SnapshotTesting | ||
import RxSwift | ||
|
||
@testable import Account | ||
|
||
class AccountViewLightTests: XCTestCase { | ||
|
||
private let factory = AccountViewControllerFactoryMock() | ||
|
||
override func setUp() { | ||
super.setUp() | ||
isRecording = false | ||
} | ||
|
||
func test_WhenViewIsLogin_thenShowLoginScreen() { | ||
// given | ||
let accountViewModel = AccountViewModelMock(state: .login) | ||
|
||
let viewController = AccountViewController(viewModel: accountViewModel, viewControllersFactory: factory) | ||
viewController.overrideUserInterfaceStyle = .light | ||
|
||
// then | ||
assertSnapshot(matching: viewController, as: .wait(for: 1, on: .image(on: .iPhoneSe))) | ||
} | ||
|
||
func test_WhenViewIsLogged_thenShowProfileScreen() { | ||
// given | ||
let accountViewModel = AccountViewModelMock(state: .profile(account: AccountResult.stub())) | ||
|
||
let viewController = AccountViewController(viewModel: accountViewModel, viewControllersFactory: factory) | ||
viewController.overrideUserInterfaceStyle = .light | ||
|
||
// then | ||
assertSnapshot(matching: viewController, as: .wait(for: 1, on: .image(on: .iPhoneSe))) | ||
} | ||
} |
66 changes: 0 additions & 66 deletions
66
Projects/Features/Account/Tests/Account/Presentation/AccountViewTests.swift
This file was deleted.
Oops, something went wrong.
Binary file added
BIN
+32.6 KB
...pshots__/AccountViewDarkTests/test_WhenViewIsLogged_thenShowProfileScreen.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+115 KB
...Snapshots__/AccountViewDarkTests/test_WhenViewIsLogin_thenShowLoginScreen.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33 KB
...shots__/AccountViewLightTests/test_WhenViewIsLogged_thenShowProfileScreen.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+117 KB
...napshots__/AccountViewLightTests/test_WhenViewIsLogin_thenShowLoginScreen.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions
52
Projects/Features/Account/Tests/SignIn/Presentation/SignInViewDarkTests.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,52 @@ | ||
// | ||
// SignInViewDarkTests.swift | ||
// AccountTests | ||
// | ||
// Created by Jeans Ruiz on 20/12/21. | ||
// | ||
|
||
import XCTest | ||
import SnapshotTesting | ||
import RxSwift | ||
|
||
@testable import Account | ||
|
||
class SignInViewDarkTests: XCTestCase { | ||
|
||
private var rootWindow: UIWindow! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
isRecording = false | ||
} | ||
|
||
func test_WhenViewIsInitial_thenShowInitialScreen() { | ||
// given | ||
let signInViewModel = SignInViewModelMock(state: .initial) | ||
let viewController = SignInViewController(viewModel: signInViewModel) | ||
viewController.overrideUserInterfaceStyle = .dark | ||
|
||
// then | ||
assertSnapshot(matching: viewController, as: .wait(for: 1, on: .image(on: .iPhoneSe))) | ||
} | ||
|
||
func test_WhenViewIsLoading_thenShowLoadingScreen() { | ||
// given | ||
let signInViewModel = SignInViewModelMock(state: .loading) | ||
let viewController = SignInViewController(viewModel: signInViewModel) | ||
viewController.overrideUserInterfaceStyle = .dark | ||
|
||
// then | ||
assertSnapshot(matching: viewController, as: .wait(for: 1, on: .image(on: .iPhoneSe))) | ||
} | ||
|
||
func test_WhenViewIsError_thenShowErrorScreen() { | ||
// given | ||
let signInViewModel = SignInViewModelMock(state: .error) | ||
let viewController = SignInViewController(viewModel: signInViewModel) | ||
viewController.overrideUserInterfaceStyle = .dark | ||
|
||
// then | ||
assertSnapshot(matching: viewController, as: .wait(for: 1, on: .image(on: .iPhoneSe))) | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
Projects/Features/Account/Tests/SignIn/Presentation/SignInViewLightTests.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,52 @@ | ||
// | ||
// SignInViewLightTests.swift | ||
// AccountTVTests | ||
// | ||
// Created by Jeans Ruiz on 8/8/20. | ||
// | ||
|
||
import XCTest | ||
import SnapshotTesting | ||
import RxSwift | ||
|
||
@testable import Account | ||
|
||
class SignInViewLightTests: XCTestCase { | ||
|
||
private var rootWindow: UIWindow! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
isRecording = false | ||
} | ||
|
||
func test_WhenViewIsInitial_thenShowInitialScreen() { | ||
// given | ||
let signInViewModel = SignInViewModelMock(state: .initial) | ||
let viewController = SignInViewController(viewModel: signInViewModel) | ||
viewController.overrideUserInterfaceStyle = .light | ||
|
||
// then | ||
assertSnapshot(matching: viewController, as: .wait(for: 1, on: .image(on: .iPhoneSe))) | ||
} | ||
|
||
func test_WhenViewIsLoading_thenShowLoadingScreen() { | ||
// given | ||
let signInViewModel = SignInViewModelMock(state: .loading) | ||
let viewController = SignInViewController(viewModel: signInViewModel) | ||
viewController.overrideUserInterfaceStyle = .light | ||
|
||
// then | ||
assertSnapshot(matching: viewController, as: .wait(for: 1, on: .image(on: .iPhoneSe))) | ||
} | ||
|
||
func test_WhenViewIsError_thenShowErrorScreen() { | ||
// given | ||
let signInViewModel = SignInViewModelMock(state: .error) | ||
let viewController = SignInViewController(viewModel: signInViewModel) | ||
viewController.overrideUserInterfaceStyle = .light | ||
|
||
// then | ||
assertSnapshot(matching: viewController, as: .wait(for: 1, on: .image(on: .iPhoneSe))) | ||
} | ||
} |
54 changes: 0 additions & 54 deletions
54
Projects/Features/Account/Tests/SignIn/Presentation/SignInViewTests.swift
This file was deleted.
Oops, something went wrong.
Binary file added
BIN
+115 KB
..._Snapshots__/SignInViewDarkTests/test_WhenViewIsError_thenShowErrorScreen.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+115 KB
...pshots__/SignInViewDarkTests/test_WhenViewIsInitial_thenShowInitialScreen.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+94.9 KB
...pshots__/SignInViewDarkTests/test_WhenViewIsLoading_thenShowLoadingScreen.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+117 KB
...Snapshots__/SignInViewLightTests/test_WhenViewIsError_thenShowErrorScreen.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+117 KB
...shots__/SignInViewLightTests/test_WhenViewIsInitial_thenShowInitialScreen.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+96 KB
...shots__/SignInViewLightTests/test_WhenViewIsLoading_thenShowLoadingScreen.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
37 changes: 37 additions & 0 deletions
37
Projects/Features/AiringToday/Tests/Mocks/AiringTodayViewModelMock.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,37 @@ | ||
// | ||
// AiringTodayViewModelMock.swift | ||
// AiringTodayTests | ||
// | ||
// Created by Jeans Ruiz on 19/12/21. | ||
// | ||
|
||
import Shared | ||
import RxSwift | ||
@testable import AiringToday | ||
|
||
class AiringTodayViewModelMock: AiringTodayViewModelProtocol { | ||
|
||
func viewDidLoad() { } | ||
|
||
func didLoadNextPage() { } | ||
|
||
func showIsPicked(with id: Int) { } | ||
|
||
func refreshView() { } | ||
|
||
func getCurrentViewState() -> SimpleViewState<AiringTodayCollectionViewModel> { | ||
if let currentViewState = try? viewStateObservableSubject.value() { | ||
return currentViewState | ||
} | ||
return .empty | ||
} | ||
|
||
var viewState: Observable<SimpleViewState<AiringTodayCollectionViewModel>> | ||
|
||
var viewStateObservableSubject: BehaviorSubject<SimpleViewState<AiringTodayCollectionViewModel>> | ||
|
||
init(state: SimpleViewState<AiringTodayCollectionViewModel>) { | ||
viewStateObservableSubject = BehaviorSubject(value: state) | ||
viewState = viewStateObservableSubject.asObservable() | ||
} | ||
} |
Oops, something went wrong.