Last active
January 7, 2019 11:15
-
-
Save pedrommcarrasco/db355b8285b5b4a2467a4d2b097679c7 to your computer and use it in GitHub Desktop.
Let's Talk About: Double Standards - Copy-Pastability (after)
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
private enum Constant { | |
static let scenarioAFile = "screenScenarioA" | |
static let scenarioBFile = "screenScenarioB" | |
} | |
func testScenarioA() { | |
// Arrange & Act | |
updateStructureWithJSON(named: Constant.scenarioAFile) | |
let result = screenStructureManager.current | |
let expectedResult: [Component] = [.header, .products] | |
// Assert | |
XCTAssertEqual(result, expectedResult) | |
} | |
func testScenarioB() { | |
// Arrange & Act | |
updateStructureWithJSON(named: Constant.scenarioBFile) | |
let result = structureManager.current | |
let expectedResult: [Component] = [.header, .promoBanner, .products, .footer] | |
// Assert | |
XCTAssertEqual(result, expectedResult) | |
} | |
private func updateStructureWithJSON(named fileName: String) { | |
guard let filePath = Bundle(for: type(of: self)).path(forResource: fileName, ofType: FileType.json), | |
let data = try? Data(contentsOf: URL(fileURLWithPath: filePath)), | |
let jsonObject = try? JSONSerialization.jsonObject(with: data, options: .allowFragments), | |
else { return XCTFail("Failed to load JSON") } | |
screenStructureManager.update(with: jsonObject) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment