Group Group Group Group Group Group Group Group Group

Chapter 10 - Testing the view model

In chapter 10 we’re introduced to the view model. The instructions suggest that we optimize the view model by writing a function such as:

extension PetViewModel {
  public func configure(_ view: PetView) {
    view.nameLabel.text = name
    view.imageView.image = image
    view.ageLabel.text = ageText
    view.adoptionFeeLabel.text = adoptionFeeText
  }
}

How should we test this code? Should we instantiate a PetView in our unit tests and check its properties?

@nservidio Thanks very much for your question!

Yes, that is the point of your unit test checking the viewModel :slight_smile:
Check to see if all of your properties are set.