-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CardDetailViewController unit tests
- Loading branch information
Showing
6 changed files
with
167 additions
and
11 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
SWDestinyTrades/Classes/CardDetail/Protocol/CardViewType.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 @@ | ||
// | ||
// CardViewType.swift | ||
// SWDestinyTrades | ||
// | ||
// Created by Diogo Autilio on 25/01/24. | ||
// Copyright © 2024 Diogo Autilio. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import ImageSlideshow | ||
import UIKit | ||
|
||
protocol CardViewType where Self: UIView { | ||
|
||
var currentPageChanged: ((_ page: Int) -> Void)? { get set } | ||
|
||
func setSlideshowImageInputs(_ imageInputs: [InputSource]) | ||
func setCurrentPage(_ page: Int, animated: Bool) | ||
func getCurrentPage() -> Int | ||
func getCurrentSlideshowItem() -> ImageSlideshowItem? | ||
} |
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
31 changes: 31 additions & 0 deletions
31
SWDestinyTradesTests/Screens/CardDetail/Doubles/CardDetailPresenterSpy.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,31 @@ | ||
// | ||
// CardDetailPresenterSpy.swift | ||
// SWDestinyTradesTests | ||
// | ||
// Created by Diogo Autilio on 25/01/24. | ||
// Copyright © 2024 Diogo Autilio. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
@testable import SWDestinyTrades | ||
|
||
final class CardDetailPresenterSpy: CardDetailPresenterProtocol { | ||
|
||
private(set) var didCallViewDidLoadCount = 0 | ||
func viewDidLoad() { | ||
didCallViewDidLoadCount += 1 | ||
} | ||
|
||
private(set) var didCallSetNavigationTitleCount = 0 | ||
func setNavigationTitle() { | ||
didCallSetNavigationTitleCount += 1 | ||
} | ||
|
||
private(set) var didCallSetupNavigationItemsCount = 0 | ||
func setupNavigationItems(completion: ([UIBarButtonItem]?) -> Void) { | ||
didCallSetupNavigationItemsCount += 1 | ||
completion([]) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
SWDestinyTradesTests/Screens/CardDetail/Doubles/CardViewSpy.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,40 @@ | ||
// | ||
// CardViewSpy.swift | ||
// SWDestinyTradesTests | ||
// | ||
// Created by Diogo Autilio on 25/01/24. | ||
// Copyright © 2024 Diogo Autilio. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import ImageSlideshow | ||
import UIKit | ||
|
||
@testable import SWDestinyTrades | ||
|
||
final class CardViewSpy: UIView, CardViewType { | ||
|
||
var currentPageChanged: ((Int) -> Void)? | ||
|
||
private(set) var didCallSetSlideshowImageInputs = [InputSource]() | ||
func setSlideshowImageInputs(_ imageInputs: [InputSource]) { | ||
didCallSetSlideshowImageInputs.append(contentsOf: imageInputs) | ||
} | ||
|
||
private(set) var didCallSetCurrentPage = [(page: Int, animated: Bool)]() | ||
func setCurrentPage(_ page: Int, animated: Bool) { | ||
didCallSetCurrentPage.append((page, animated)) | ||
} | ||
|
||
private(set) var didCallGetCurrentPageCount = 0 | ||
func getCurrentPage() -> Int { | ||
didCallGetCurrentPageCount += 1 | ||
return 0 | ||
} | ||
|
||
private(set) var didCallGetCurrentSlideshowItemCount = 0 | ||
func getCurrentSlideshowItem() -> ImageSlideshowItem? { | ||
didCallGetCurrentSlideshowItemCount += 1 | ||
return nil | ||
} | ||
} |