Skip to content

Commit 1918baf

Browse files
committed
Update tests for objcpp
1 parent 7c25c2c commit 1918baf

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

packages/core/test/expo-plugin/modifyAppDelegate.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface MockedExpoConfig extends ExpoConfig {
1717
modResults: {
1818
path: string;
1919
contents: string;
20-
language: 'swift' | 'objc';
20+
language: 'swift' | 'objc' | 'objcpp' | string;
2121
};
2222
}
2323

@@ -148,6 +148,30 @@ describe('modifyAppDelegate', () => {
148148
expect(result.modResults.contents).toBe(objcExpected);
149149
});
150150

151+
it('should modify an Objective-C++ file by adding the RNSentrySDK import and start', async () => {
152+
config.modResults.language = 'objcpp';
153+
config.modResults.contents = objcContents;
154+
155+
const result = (await modifyAppDelegate(config)) as MockedExpoConfig;
156+
157+
expect(result.modResults.contents).toContain('#import <RNSentry/RNSentry.h>');
158+
expect(result.modResults.contents).toContain('[RNSentrySDK start];');
159+
expect(result.modResults.contents).toBe(objcExpected);
160+
});
161+
162+
it('should not modify a source file if the language is not supported', async () => {
163+
config.modResults.language = 'cpp';
164+
config.modResults.contents = objcContents;
165+
config.modResults.path = 'samples/react-native/ios/AppDelegate.cpp';
166+
167+
const result = (await modifyAppDelegate(config)) as MockedExpoConfig;
168+
169+
expect(warnOnce).toHaveBeenCalledWith(
170+
`Unsupported language 'cpp' detected in 'AppDelegate.cpp', the native code won't be updated.`,
171+
);
172+
expect(result).toBe(config); // No modification
173+
});
174+
151175
it('should insert import statements only once in an Swift project', async () => {
152176
config.modResults.contents =
153177
'import UIKit\nimport RNSentrySDK\n\noverride func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {';

0 commit comments

Comments
 (0)