How to unit test the UIView shown correctly or not?

Viewed 772

I have a UIView (contentBGView) that have represent border view . task is if url available the show border and if not then show without border.

How can I unit test this code?

  if contentUrlExists {
                addSubview(contentBGView)
                contentBGView.addSubview(contentTextView)
                contentBGView.addSubview(mediaView)
                contentBGView.isHidden = false
                statesTextView.anchor(locationLabel.bottomAnchor, left:  self.leftAnchor, bottom: contentBGView.topAnchor, right: self.rightAnchor, topConstant: 5, leftConstant: 10, bottomConstant: 2, rightConstant: 5, widthConstant: 0, heightConstant: 0)
                contentBGView.anchor(statesTextView.bottomAnchor, left:  self.leftAnchor, bottom: statisticsSlidingBarCollectionView.topAnchor, right: self.rightAnchor, topConstant: 0, leftConstant: 5, bottomConstant: 10, rightConstant: 5, widthConstant: 0, heightConstant: 0)
                mediaView.anchor(contentBGView.topAnchor, left:  contentBGView.leftAnchor, bottom: nil, right: contentBGView.rightAnchor, topConstant: 5, leftConstant: 4, bottomConstant: 2, rightConstant: 4, widthConstant: 0, heightConstant: 0)
                contentTextView.anchor(mediaView.bottomAnchor, left:  contentBGView.leftAnchor, bottom: contentBGView.bottomAnchor, right: contentBGView.rightAnchor, topConstant: 5, leftConstant: 5, bottomConstant: 2, rightConstant: 5, widthConstant: 0, heightConstant: stateConetentTextHeight)
                statisticsSlidingBarCollectionView.anchor(contentBGView.bottomAnchor, left: self.leftAnchor, bottom: self.bottomAnchor, right: self.rightAnchor, topConstant: 0, leftConstant: 5, bottomConstant: 0, rightConstant: 5, widthConstant: 0, heightConstant: 45)
            }else{
                addSubview(mediaView)
                contentBGView.isHidden = true
                statesTextView.anchor(locationLabel.bottomAnchor, left:  self.leftAnchor, bottom: mediaView.topAnchor, right: self.rightAnchor, topConstant: 5, leftConstant: 10, bottomConstant: 2, rightConstant: 5, widthConstant: 0, heightConstant: 0)
                mediaView.anchor(statesTextView.bottomAnchor, left:  self.leftAnchor, bottom: statisticsSlidingBarCollectionView.topAnchor, right: self.rightAnchor, topConstant: 0, leftConstant: 0, bottomConstant: 2, rightConstant: 0, widthConstant: 0, heightConstant: 160)
                statisticsSlidingBarCollectionView.anchor(mediaView.bottomAnchor, left: self.leftAnchor, bottom: self.bottomAnchor, right: self.rightAnchor, topConstant: 0, leftConstant: 5, bottomConstant: 0, rightConstant: 5, widthConstant: 0, heightConstant: 45)
            }

Unit test for border is shown correctly based on the content URL.
Thanks

1 Answers
Related