serve-sim 0.1.49-beta.141.1 → 0.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ import XCTest
2
+ @testable import SimNativeSupport
3
+
4
+ final class DeviceSetTests: XCTestCase {
5
+ override func tearDown() {
6
+ DeviceSet.configure(path: nil)
7
+ super.tearDown()
8
+ }
9
+
10
+ func testUnsetMeansXcodesDefaultSet() {
11
+ XCTAssertNil(DeviceSet.path())
12
+ XCTAssertEqual(
13
+ DeviceSet.simctlArguments(["launch", "UDID", "com.apple.springboard"]),
14
+ ["simctl", "launch", "UDID", "com.apple.springboard"]
15
+ )
16
+ }
17
+
18
+ func testConfiguredSetGoesBeforeTheVerb() {
19
+ DeviceSet.configure(path: "/pool/devices")
20
+ XCTAssertEqual(DeviceSet.path(), "/pool/devices")
21
+ XCTAssertEqual(
22
+ DeviceSet.simctlArguments(["spawn", "UDID", "/tmp/tool"]),
23
+ ["simctl", "--set", "/pool/devices", "spawn", "UDID", "/tmp/tool"]
24
+ )
25
+ DeviceSet.configure(path: nil)
26
+ XCTAssertNil(DeviceSet.path())
27
+ }
28
+
29
+ func testLookUpAsksForXcodesDefaultSetWhenUnset() {
30
+ var asked: (selector: String, path: String?)?
31
+ let found = DeviceSet.lookUp { selector, path -> String? in
32
+ asked = (selector, path)
33
+ return "default set"
34
+ }
35
+ XCTAssertEqual(found, "default set")
36
+ XCTAssertEqual(asked?.selector, "defaultDeviceSetWithError:")
37
+ XCTAssertNil(asked?.path)
38
+ }
39
+
40
+ func testLookUpAsksForTheConfiguredSetByPath() {
41
+ DeviceSet.configure(path: "/pool/devices")
42
+ var asked: (selector: String, path: String?)?
43
+ let found = DeviceSet.lookUp { selector, path -> String? in
44
+ asked = (selector, path)
45
+ return "pool set"
46
+ }
47
+ XCTAssertEqual(found, "pool set")
48
+ XCTAssertEqual(asked?.selector, "deviceSetWithPath:error:")
49
+ XCTAssertEqual(asked?.path, "/pool/devices")
50
+ }
51
+
52
+ func testLookUpIsNilWhenNoSetIsFound() {
53
+ XCTAssertNil(DeviceSet.lookUp { _, _ -> String? in nil })
54
+ DeviceSet.configure(path: "/pool/devices")
55
+ XCTAssertNil(DeviceSet.lookUp { _, _ -> String? in nil })
56
+ }
57
+ }