Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/home view model test #196

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

VitorCampos28
Copy link
Contributor

------------ APAGAR ------------
Emojis para os titulos dos MR's

  • ✨ - Introduce new features
  • 🚧 - Work in progress
    More on: https://gitmoji.dev
    ------------ APAGAR ------------

Descrição simples da nova feature

Checklist:

Coloque um x nas caixas que se aplicam.

  • Não adiciona código duplicado
  • Não contém código comentado
  • Não contém código WIP

Evidências da feature:

Captura de Tela 2022-11-18 às 14 18 04
Captura de Tela 2022-11-18 às 14 19 24

let delegateSpy = HomeViewModelDelegateSpy()
lazy var sut = HomeViewModel(financeService: financeServiceSpy, dispatchQueue: dispatchQueueSpy)

func test_didFetchHomeData_isCalled () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func test_didFetchHomeData_isCalled () {
func test_fetchHomeData_shouldCallDelegate() {

XCTAssertTrue(delegateSpy.delegateIsCalled)
}

func test_fetchHomeDataAndDispatchQueue_isCalled() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func test_fetchHomeDataAndDispatchQueue_isCalled() {
func test_fetchHomeData_whenDataIsNotNil_shouldCallDispatch() {

XCTAssertTrue(dispatchQueueSpy.isDispatchCalled)
}

func test_fetchData_shouldNotCallDelegate_whenHomedataIsNill () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func test_fetchData_shouldNotCallDelegate_whenHomedataIsNill () {
func test_fetchData_whenHomedataIsNill _shouldNotCallDelegate() {

}

class HomeViewModelDelegateSpy: HomeViewModelDelegate {
var delegateIsCalled: Bool = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var delegateIsCalled: Bool = false
private(set) var delegateIsCalled: Bool = false


class FinanceServiceSpy: FetchHomeDataProtocol {

var homeData: HomeData? = HomeData(balance: 0, savings: 0, spending: 0, activity: [Activity(name: "", price: 0, time: "")])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O que você acha de utilizarmos uma fixture

class FinanceServiceSpy: FetchHomeDataProtocol {

var homeData: HomeData? = HomeData(balance: 0, savings: 0, spending: 0, activity: [Activity(name: "", price: 0, time: "")])
var fetchHomeDataIsCalled: Bool = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var fetchHomeDataIsCalled: Bool = false
private(set) var fetchHomeDataIsCalled: Bool = false

@@ -5,7 +5,12 @@ import Foundation
@testable import FinanceApp

public class DispatchQueueSpy: DispatchQueueProtocol {

var isDispatchCalled: Bool = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var isDispatchCalled: Bool = false
private(set) var isDispatchCalled: Bool = false

@@ -5,7 +5,12 @@ import Foundation
@testable import FinanceApp

public class DispatchQueueSpy: DispatchQueueProtocol {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class DispatchQueueSpy: DispatchQueueProtocol {
final class DispatchQueueSpy: DispatchQueueProtocol {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants