Skip to content

Commit

Permalink
Add tests to parse simulator on Xcode 10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
giginet committed Oct 6, 2018
1 parent 41bc729 commit 2d4f8d2
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"devices" : {
"iOS 12.0" : [
{
"state" : "Shutdown",
"isAvailable" : "YES",
"name" : "iPhone 5s",
"udid" : "A52BF797-F6F8-47F1-B559-68B66B553B23"
},
{
"state" : "Shutdown",
"isAvailable" : "YES",
"name" : "iPhone 6",
"udid" : "ABDA7BC1-DB72-4332-90C2-C3D9AA8A5003"
},
],
"watchOS 4.2" : [
{
"state" : "Shutdown",
"isAvailable" : "YES",
"name" : "Apple Watch - 38mm",
"udid" : "290C3D57-0FF0-407F-B33C-F1A55EA44019"
},
{
"state" : "Shutdown",
"isAvailable" : "YES",
"name" : "Apple Watch - 42mm",
"udid" : "6F499604-363C-4AC8-B5D4-73742CA4D674"
},
],
"iOS 8.4" : [
{
"state" : "Shutdown",
"isAvailable" : "YES",
"name" : "iPhone 4s",
"udid" : "F6E70576-0167-448C-AE00-4AC624552796"
},
{
"state" : "Shutdown",
"isAvailable" : "YES",
"name" : "iPhone 5",
"udid" : "CF663E57-B922-4911-A118-C62497C77739"
},
],
}
}
44 changes: 31 additions & 13 deletions Tests/CarthageKitTests/SimulatorSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,38 @@ class SimulatorSpec: QuickSpec {
let url = Bundle(for: type(of: self)).url(forResource: resource, withExtension: "json")!
return try! Data(contentsOf: url)
}

describe("Simulator") {
it("should be parsed") {
let decoder = JSONDecoder()
let data = loadJSON(for: "Simulators/availables")
let dictionary = try! decoder.decode([String: [String: [Simulator]]].self, from: data)
let devices = dictionary["devices"]!

let simulators = devices["iOS 12.0"]!
expect(simulators.count).to(equal(2))
let simulator = simulators.first!
expect(simulator.udid).to(equal(UUID(uuidString: "A52BF797-F6F8-47F1-B559-68B66B553B23")!))
expect(simulator.isAvailable).to(beTrue())
expect(simulator.name).to(equal("iPhone 5s"))
context("Xcode 10.0 or lower") {
it("should be parsed") {
let decoder = JSONDecoder()
let data = loadJSON(for: "Simulators/availables")
let dictionary = try! decoder.decode([String: [String: [Simulator]]].self, from: data)
let devices = dictionary["devices"]!

let simulators = devices["iOS 12.0"]!
expect(simulators.count).to(equal(2))
let simulator = simulators.first!
expect(simulator.udid).to(equal(UUID(uuidString: "A52BF797-F6F8-47F1-B559-68B66B553B23")!))
expect(simulator.isAvailable).to(beTrue())
expect(simulator.name).to(equal("iPhone 5s"))
}
}

context("Xcode 10.1 or above") {
it("should be parsed") {
let decoder = JSONDecoder()
let data = loadJSON(for: "Simulators/availables-xcode101")
let dictionary = try! decoder.decode([String: [String: [Simulator]]].self, from: data)
let devices = dictionary["devices"]!

let simulators = devices["iOS 12.0"]!
expect(simulators.count).to(equal(2))
let simulator = simulators.first!
expect(simulator.udid).to(equal(UUID(uuidString: "A52BF797-F6F8-47F1-B559-68B66B553B23")!))
expect(simulator.isAvailable).to(beTrue())
expect(simulator.name).to(equal("iPhone 5s"))
}
}
}

Expand Down

0 comments on commit 2d4f8d2

Please sign in to comment.