Last active
January 7, 2019 11:16
-
-
Save pedrommcarrasco/d8108a5519e9ee4fee1965d8cb0671f9 to your computer and use it in GitHub Desktop.
Let's Talk About: Double Standards - Copy-Pastability (before)
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 | |
guard let filePath = Bundle(for: type(of: self)).path(forResource: Constant.scenarioAFile, 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") } | |
// Act | |
screenStructureManager.update(with: jsonObject) | |
let result = screenStructureManager.current | |
let expectedResult: [Component] = [.header, .products] | |
// Assert | |
XCTAssertEqual(result, expectedResult) | |
} | |
func testScenarioB() { | |
// Arrange | |
guard let filePath = Bundle(for: type(of: self)).path(forResource: Constant.scenarioBFile, 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") } | |
// Act | |
screenStructureManager.update(with: jsonObject) | |
let result = screenStructureManager.current | |
let expectedResult: [Component] = [.header, .promoBanner, .products, .footer] | |
// Assert | |
XCTAssertEqual(result, expectedResult) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment