Skip to content

Commit

Permalink
Stabilise the snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjgalloway committed Sep 27, 2020
1 parent 8b945c4 commit ae1a429
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
11 changes: 9 additions & 2 deletions EmonCMSiOSTests/SnapshotTests/FeedCellTests.swift
Expand Up @@ -24,13 +24,20 @@ class FeedCellTests: EmonCMSTestCase {

override func spec() {
var tableView: UITableView!
var traits: UITraitCollection!

beforeEach {
tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 375, height: 700), style: .plain)
tableView.dataSource = self
tableView.delegate = self
tableView.register(UINib(nibName: "FeedCell", bundle: nil), forCellReuseIdentifier: "FeedCell")

traits =
UITraitCollection(traitsFrom: [
UITraitCollection(displayScale: 2.0),
UITraitCollection(userInterfaceStyle: .light)
])

self.cellSetup = { _ in }
}

Expand All @@ -43,7 +50,7 @@ class FeedCellTests: EmonCMSTestCase {
cell.activityCircle.backgroundColor = EmonCMSColors.ActivityIndicator.Green
cell.chartViewModel.send(nil)
}
assertSnapshot(matching: tableView, as: .image(traits: .init(userInterfaceStyle: .light)))
assertSnapshot(matching: tableView, as: .image(traits: traits))
}

it("Should display expanded") {
Expand All @@ -54,7 +61,7 @@ class FeedCellTests: EmonCMSTestCase {
cell.activityCircle.backgroundColor = EmonCMSColors.ActivityIndicator.Green
cell.chartViewModel.send(self.makeFeedChartViewModel())
}
assertSnapshot(matching: tableView, as: .image(traits: .init(userInterfaceStyle: .light)))
assertSnapshot(matching: tableView, as: .image(traits: traits))
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion EmonCMSiOSTests/SnapshotTests/InputCellTests.swift
Expand Up @@ -22,13 +22,20 @@ class InputCellTests: EmonCMSTestCase {

override func spec() {
var tableView: UITableView!
var traits: UITraitCollection!

beforeEach {
tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 375, height: 700), style: .plain)
tableView.dataSource = self
tableView.delegate = self
tableView.register(UINib(nibName: "InputCell", bundle: nil), forCellReuseIdentifier: "InputCell")

traits =
UITraitCollection(traitsFrom: [
UITraitCollection(displayScale: 2.0),
UITraitCollection(userInterfaceStyle: .light)
])

self.cellSetup = { _ in }
}

Expand All @@ -40,7 +47,7 @@ class InputCellTests: EmonCMSTestCase {
cell.timeLabel.text = "10 seconds ago"
cell.activityCircle.backgroundColor = EmonCMSColors.ActivityIndicator.Green
}
assertSnapshot(matching: tableView, as: .image(traits: .init(userInterfaceStyle: .light)))
assertSnapshot(matching: tableView, as: .image(traits: traits))
}
}
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ae1a429

Please sign in to comment.