Skip to content

Commit 4ab878c

Browse files
author
Mark de Vocht
committed
snapshot update for linker test
1 parent 2570749 commit 4ab878c

2 files changed

Lines changed: 66 additions & 5 deletions

File tree

autolink/postlink/__snapshots__/appDelegateLinker.test.js.snap

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`appDelegateLinker should work for RN 0.77 with Objective-C 1`] = `
3+
exports[`appDelegateLinker should work for RN 0.77 & 0.78 with Objective-C 1`] = `
44
"#import "AppDelegate.h"
55
#import <ReactNativeNavigation/ReactNativeNavigation.h>
66
@@ -36,7 +36,7 @@ exports[`appDelegateLinker should work for RN 0.77 with Objective-C 1`] = `
3636
@end "
3737
`;
3838

39-
exports[`appDelegateLinker should work for RN 0.77 with Swift 1`] = `
39+
exports[`appDelegateLinker should work for RN 0.77 & 0.78 with Swift 1`] = `
4040
"import UIKit
4141
import React
4242
import ReactNativeNavigation
@@ -68,3 +68,40 @@ class AppDelegate: RNNAppDelegate {
6868
}
6969
} "
7070
`;
71+
72+
exports[`appDelegateLinker should work with Swift bridgeless RN 0.79 1`] = `
73+
"import UIKit
74+
import React
75+
import ReactNativeNavigation
76+
import ReactAppDependencyProvider
77+
78+
@main
79+
class AppDelegate: RNNAppDelegate {
80+
81+
override func application(
82+
_ application: UIApplication,
83+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
84+
) -> Bool {
85+
self.reactNativeDelegate = ReactNativeDelegate()
86+
super.application(application, didFinishLaunchingWithOptions: launchOptions)
87+
88+
89+
90+
return true
91+
}
92+
}
93+
94+
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
95+
override func sourceURL(for bridge: RCTBridge) -> URL? {
96+
self.bundleURL()
97+
}
98+
99+
override func bundleURL() -> URL? {
100+
#if DEBUG
101+
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
102+
#else
103+
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
104+
#endif
105+
}
106+
}"
107+
`;

autolink/postlink/appDelegateLinker.test.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ import * as mockHelpers from './__helpers__/fixtures';
44
jest.mock('./log');
55

66
describe('appDelegateLinker', () => {
7-
it('should work for RN 0.77 with Objective-C', () => {
7+
it('should work for RN 0.77 & 0.78 with Objective-C', () => {
8+
const { getReactNativeVersion } = require('./__helpers__/reactNativeVersion');
9+
const rnVersion = getReactNativeVersion();
10+
11+
if (rnVersion && rnVersion.minor >= 79) {
12+
console.log(`Skipping RN 0.77 test (current version: ${rnVersion.raw})`);
13+
return;
14+
}
15+
816
jest.mock('./path', () => {
917
const appDelegatePath = mockHelpers.prepareFixtureDuplicate77({
1018
userFixtureFileName: 'AppDelegate.mm.template',
@@ -23,7 +31,15 @@ describe('appDelegateLinker', () => {
2331
expect(appDelegateContent).toMatchSnapshot();
2432
});
2533

26-
it('should work for RN 0.77 with Swift', () => {
34+
it('should work for RN 0.77 & 0.78 with Swift', () => {
35+
const { getReactNativeVersion } = require('./__helpers__/reactNativeVersion');
36+
const rnVersion = getReactNativeVersion();
37+
38+
if (rnVersion && rnVersion.minor >= 79) {
39+
console.log(`Skipping RN 0.77 test (current version: ${rnVersion.raw})`);
40+
return;
41+
}
42+
2743
jest.mock('./path', () => {
2844
const tmpAppDelegatePath = mockHelpers.prepareFixtureDuplicate77({
2945
userFixtureFileName: 'AppDelegate.swift.template',
@@ -43,7 +59,15 @@ describe('appDelegateLinker', () => {
4359
expect(appDelegateContent).toMatchSnapshot();
4460
});
4561

46-
it('should work with Swift bridgeless RN 0.79+', () => {
62+
it('should work with Swift bridgeless RN 0.79', () => {
63+
const { getReactNativeVersion } = require('./__helpers__/reactNativeVersion');
64+
const rnVersion = getReactNativeVersion();
65+
66+
if (!rnVersion || rnVersion.minor < 79) {
67+
console.log(`Skipping RN 0.79 test (current version: ${rnVersion?.raw || 'unknown'})`);
68+
return;
69+
}
70+
4771
jest.mock('./path', () => {
4872
const tmpAppDelegatePath = mockHelpers.prepareFixtureDuplicate79({
4973
userFixtureFileName: 'AppDelegate.swift.template',

0 commit comments

Comments
 (0)