1import { AndroidConfig, AndroidManifest } from '@expo/config-plugins'; 2 3import { 4 removeExpoSchemaFromVerifiedIntentFilters, 5 setGeneratedAndroidScheme, 6} from '../withGeneratedAndroidScheme'; 7 8describe(setGeneratedAndroidScheme, () => { 9 it(`prevents adding duplicates`, () => { 10 let androidManifest: AndroidManifest = { 11 manifest: { 12 application: [ 13 { 14 activity: [ 15 { 16 $: { 17 'android:name': '.MainActivity', 18 'android:launchMode': 'singleTask', 19 }, 20 'intent-filter': [ 21 { 22 action: [ 23 { 24 $: { 25 'android:name': 'android.intent.action.VIEW', 26 }, 27 }, 28 ], 29 category: [ 30 { 31 $: { 32 'android:name': 'android.intent.category.DEFAULT', 33 }, 34 }, 35 { 36 $: { 37 'android:name': 'android.intent.category.BROWSABLE', 38 }, 39 }, 40 ], 41 data: [], 42 }, 43 ], 44 }, 45 ], 46 $: { 47 'android:name': '.MainApplication', 48 }, 49 }, 50 ], 51 $: { 52 'xmlns:android': 'http://schemas.android.com/apk/res/android', 53 package: 'com.placeholder.appid', 54 }, 55 }, 56 }; 57 const config = { slug: 'cello' }; 58 59 for (let i = 0; i < 2; i++) { 60 androidManifest = setGeneratedAndroidScheme(config, androidManifest); 61 62 expect(AndroidConfig.Scheme.getSchemesFromManifest(androidManifest)).toStrictEqual([ 63 'exp+cello', 64 ]); 65 } 66 }); 67 68 it(`removes exp+ scheme when intent filter autoVerify is true`, () => { 69 let androidManifest: AndroidManifest = { 70 manifest: { 71 application: [ 72 { 73 activity: [ 74 { 75 $: { 76 'android:name': '.MainActivity', 77 'android:launchMode': 'singleTask', 78 }, 79 'intent-filter': [ 80 { 81 $: { 82 'android:autoVerify': 'true', 83 }, 84 action: [ 85 { 86 $: { 87 'android:name': 'android.intent.action.VIEW', 88 }, 89 }, 90 ], 91 category: [ 92 { 93 $: { 94 'android:name': 'android.intent.category.DEFAULT', 95 }, 96 }, 97 { 98 $: { 99 'android:name': 'android.intent.category.BROWSABLE', 100 }, 101 }, 102 ], 103 data: [], 104 }, 105 { 106 action: [ 107 { 108 $: { 109 'android:name': 'android.intent.action.VIEW', 110 }, 111 }, 112 ], 113 category: [ 114 { 115 $: { 116 'android:name': 'android.intent.category.DEFAULT', 117 }, 118 }, 119 { 120 $: { 121 'android:name': 'android.intent.category.BROWSABLE', 122 }, 123 }, 124 ], 125 data: [], 126 }, 127 ], 128 }, 129 ], 130 $: { 131 'android:name': '.MainApplication', 132 }, 133 }, 134 ], 135 $: { 136 'xmlns:android': 'http://schemas.android.com/apk/res/android', 137 package: 'com.placeholder.appid', 138 }, 139 }, 140 }; 141 const config = { slug: 'cello' }; 142 androidManifest = setGeneratedAndroidScheme(config, androidManifest); 143 androidManifest = removeExpoSchemaFromVerifiedIntentFilters(config, androidManifest); 144 const schemes = AndroidConfig.Scheme.getSchemesFromManifest(androidManifest); 145 expect(schemes.length).toEqual(1); 146 }); 147}); 148