expo-dev-launcher 5.0.0 → 5.0.2

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,26 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+
3
+ import Quick
4
+ import Nimble
5
+ import React
6
+
7
+ @testable import EXDevLauncher
8
+
9
+ internal class MockBridgeDelegate: NSObject, RCTBridgeDelegate {
10
+ var loadSourceCalled = false
11
+
12
+ func sourceURL(for bridge: RCTBridge) -> URL? {
13
+ return URL(string: "http://localhost:8081/index.bundle")
14
+ }
15
+
16
+ func loadSource(for bridge: RCTBridge, onProgress: @escaping RCTSourceLoadProgressBlock, onComplete loadCallback: @escaping RCTSourceLoadBlock) {
17
+ loadSourceCalled = true
18
+
19
+ // Executes callback nil for both error and source looks strange but that's the only way we can bypass the lock
20
+ loadCallback(nil, nil)
21
+ }
22
+ }
23
+
24
+ internal func waitBridgeReady(bridgeDelegate: MockBridgeDelegate) {
25
+ expect(bridgeDelegate.loadSourceCalled).toEventually(beTrue())
26
+ }
@@ -21,9 +21,10 @@ class EXDevLauncherControllerTest: QuickSpec {
21
21
 
22
22
  it("extraModulesForBridge should return essential modules") {
23
23
  let module = EXDevLauncherController.sharedInstance()
24
- let bridge = RCTBridge(delegate: nil)
24
+ let bridgeDelegate = MockBridgeDelegate()
25
+ let bridge = RCTBridge(delegate: bridgeDelegate)
26
+ waitBridgeReady(bridgeDelegate: bridgeDelegate)
25
27
  let modules = module.extraModules(for: bridge!)
26
-
27
28
  expect(modules.first { $0 is RCTDevMenu }).toNot(beNil())
28
29
  expect(modules.first { type(of: $0).moduleName() == "DevLoadingView" }).toNot(beNil())
29
30
  }
@@ -14,13 +14,17 @@ class EXDevLauncherRCTBridgeTest: QuickSpec {
14
14
 
15
15
  override class func spec() {
16
16
  it("should be connected with EXDevLauncherRCTCxxBridge") {
17
- let bridge = EXDevLauncherRCTBridge(delegate: nil, launchOptions: nil)!
17
+ let bridgeDelegate = MockBridgeDelegate()
18
+ let bridge = EXDevLauncherRCTBridge(delegate: bridgeDelegate, launchOptions: nil)!
19
+ waitBridgeReady(bridgeDelegate: bridgeDelegate)
18
20
 
19
21
  expect(bridge.bridgeClass()).to(be(EXDevLauncherRCTCxxBridge.self))
20
22
  }
21
23
 
22
24
  it("should be able to filter non essential modules") {
23
- let cxxBridge = EXDevLauncherRCTBridge(delegate: nil, launchOptions: nil)!.batched as! EXDevLauncherRCTCxxBridge
25
+ let bridgeDelegate = MockBridgeDelegate()
26
+ let cxxBridge = EXDevLauncherRCTBridge(delegate: bridgeDelegate, launchOptions: nil)!.batched as! EXDevLauncherRCTCxxBridge
27
+ waitBridgeReady(bridgeDelegate: bridgeDelegate)
24
28
 
25
29
  let filteredModules = cxxBridge.filterModuleList([RCTAllowModule.self, NotAllowModule.self, ExpoBridgeModuleAbc.self])
26
30