|
1 | 1 | import { describe, expect, it } from '@jest/globals';
|
2 | 2 | import { setFireBaseMessagingAndroidManifest } from '../src/android/setupFirebaseNotifationIcon';
|
3 | 3 | import { ExpoConfig } from '@expo/config-types';
|
4 |
| -import expoConfigExample from './fixtures/expo-config-example'; |
| 4 | +import { expoConfigExample, expoConfigExampleWithExpoNotificationsPlugin } from './fixtures/expo-config-example'; |
5 | 5 | import manifestApplicationExample from './fixtures/application-example';
|
6 | 6 | import { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';
|
7 | 7 |
|
@@ -67,4 +67,47 @@ describe('Config Plugin Android Tests', function () {
|
67 | 67 | // eslint-disable-next-line no-console
|
68 | 68 | console.warn = warnOrig;
|
69 | 69 | });
|
| 70 | + |
| 71 | + it('applies changes to app/src/main/AndroidManifest.xml with expo-notifications plugin config when app.json notification is undefined', async function () { |
| 72 | + const config: ExpoConfig = JSON.parse(JSON.stringify(expoConfigExampleWithExpoNotificationsPlugin)); |
| 73 | + const manifestApplication: ManifestApplication = JSON.parse( |
| 74 | + JSON.stringify(manifestApplicationExample), |
| 75 | + ); |
| 76 | + config.notification = undefined; |
| 77 | + setFireBaseMessagingAndroidManifest(config, manifestApplication); |
| 78 | + expect(manifestApplication['meta-data']).toContainEqual({ |
| 79 | + $: { |
| 80 | + 'android:name': 'com.google.firebase.messaging.default_notification_icon', |
| 81 | + 'android:resource': '@drawable/notification_icon', |
| 82 | + }, |
| 83 | + }); |
| 84 | + expect(manifestApplication['meta-data']).toContainEqual({ |
| 85 | + $: { |
| 86 | + 'android:name': 'com.google.firebase.messaging.default_notification_color', |
| 87 | + 'android:resource': '@color/notification_icon_color', |
| 88 | + 'tools:replace': 'android:resource', |
| 89 | + }, |
| 90 | + }); |
| 91 | + }); |
| 92 | + |
| 93 | + it('applies changes to app/src/main/AndroidManifest.xml with app.json notification config when both configs are defined', async function () { |
| 94 | + const config: ExpoConfig = JSON.parse(JSON.stringify(expoConfigExampleWithExpoNotificationsPlugin)); |
| 95 | + const manifestApplication: ManifestApplication = JSON.parse( |
| 96 | + JSON.stringify(manifestApplicationExample), |
| 97 | + ); |
| 98 | + setFireBaseMessagingAndroidManifest(config, manifestApplication); |
| 99 | + expect(manifestApplication['meta-data']).toContainEqual({ |
| 100 | + $: { |
| 101 | + 'android:name': 'com.google.firebase.messaging.default_notification_icon', |
| 102 | + 'android:resource': '@drawable/notification_icon', |
| 103 | + }, |
| 104 | + }); |
| 105 | + expect(manifestApplication['meta-data']).toContainEqual({ |
| 106 | + $: { |
| 107 | + 'android:name': 'com.google.firebase.messaging.default_notification_color', |
| 108 | + 'android:resource': '@color/notification_icon_color', |
| 109 | + 'tools:replace': 'android:resource', |
| 110 | + }, |
| 111 | + }); |
| 112 | + }); |
70 | 113 | });
|
0 commit comments