@@ -3,12 +3,16 @@ import * as os from 'node:os';
33import * as path from 'node:path' ;
44
55import {
6- extractExpoUpdatesApplicationMetaData ,
7- readExpoUpdatesApplicationMetaData ,
8- readExpoUpdatesStringResources ,
6+ extractApplicationMetaDataFromAndroidManifest ,
7+ extractStringResourcesFromResourcesXml ,
98 renderLibraryManifestApplication ,
109 renderLibraryStringResources ,
1110} from '../androidManifest' ;
11+ import {
12+ extractExpoUpdatesApplicationMetaData ,
13+ readExpoUpdatesApplicationMetaData ,
14+ readExpoUpdatesStringResources ,
15+ } from '../expo-updates' ;
1216
1317describe ( 'android manifest helpers' , ( ) => {
1418 const tempDirectories : string [ ] = [ ] ;
@@ -124,6 +128,142 @@ describe('android manifest helpers', () => {
124128 ) ;
125129 } ) ;
126130
131+ it ( 'keeps typed extraction aligned for android:value entries and referenced string resources' , ( ) => {
132+ const androidDir = createAndroidDir ( ) ;
133+ const manifestContent = `<?xml version="1.0" encoding="utf-8"?>
134+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
135+ <application android:name=".MainApplication">
136+ <meta-data android:name="expo.modules.updates.ENABLED" android:value="true" />
137+ <meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version" />
138+ <meta-data android:name="com.example.NOT_UPDATES" android:value="ignored" />
139+ </application>
140+ </manifest>` ;
141+ const typedManifest = {
142+ manifest : {
143+ $ : {
144+ 'xmlns:android' : 'http://schemas.android.com/apk/res/android' ,
145+ } ,
146+ queries : [ ] ,
147+ application : [
148+ {
149+ $ : {
150+ 'android:name' : '.MainApplication' ,
151+ } ,
152+ 'meta-data' : [
153+ {
154+ $ : {
155+ 'android:name' : 'expo.modules.updates.ENABLED' ,
156+ 'android:value' : 'true' ,
157+ } ,
158+ } ,
159+ {
160+ $ : {
161+ 'android:name' : 'expo.modules.updates.EXPO_RUNTIME_VERSION' ,
162+ 'android:value' : '@string/expo_runtime_version' ,
163+ } ,
164+ } ,
165+ {
166+ $ : {
167+ 'android:name' : 'com.example.NOT_UPDATES' ,
168+ 'android:value' : 'ignored' ,
169+ } ,
170+ } ,
171+ ] ,
172+ } ,
173+ ] ,
174+ } ,
175+ } ;
176+
177+ writeAppStrings (
178+ androidDir ,
179+ `<?xml version="1.0" encoding="utf-8"?>
180+ <resources>
181+ <string name="expo_runtime_version">1.0.0-preview</string>
182+ </resources>`
183+ ) ;
184+
185+ const fileMetaData = extractExpoUpdatesApplicationMetaData ( manifestContent ) ;
186+ const typedMetaData = extractApplicationMetaDataFromAndroidManifest (
187+ typedManifest
188+ ) . filter ( ( { name } ) => name . startsWith ( 'expo.modules.updates.' ) ) ;
189+
190+ expect ( typedMetaData ) . toEqual ( fileMetaData ) ;
191+ expect (
192+ extractStringResourcesFromResourcesXml (
193+ {
194+ resources : {
195+ string : [
196+ {
197+ $ : { name : 'expo_runtime_version' } ,
198+ _ : '1.0.0-preview' ,
199+ } ,
200+ ] ,
201+ } ,
202+ } ,
203+ [ 'expo_runtime_version' ]
204+ )
205+ ) . toEqual ( readExpoUpdatesStringResources ( androidDir , fileMetaData ) ) ;
206+ } ) ;
207+
208+ it ( 'supports android:resource entries in the typed manifest adapter' , ( ) => {
209+ const metaDataEntries = extractApplicationMetaDataFromAndroidManifest ( {
210+ manifest : {
211+ $ : {
212+ 'xmlns:android' : 'http://schemas.android.com/apk/res/android' ,
213+ } ,
214+ queries : [ ] ,
215+ application : [
216+ {
217+ $ : {
218+ 'android:name' : '.MainApplication' ,
219+ } ,
220+ 'meta-data' : [
221+ {
222+ $ : {
223+ 'android:name' : 'expo.modules.updates.EXPO_RUNTIME_VERSION' ,
224+ 'android:resource' : '@string/expo_runtime_version' ,
225+ } ,
226+ } ,
227+ {
228+ $ : {
229+ 'android:name' : 'com.example.NOT_UPDATES' ,
230+ 'android:resource' : '@string/ignored' ,
231+ } ,
232+ } ,
233+ ] ,
234+ } ,
235+ ] ,
236+ } ,
237+ } ) . filter ( ( { name } ) => name . startsWith ( 'expo.modules.updates.' ) ) ;
238+
239+ expect ( metaDataEntries ) . toEqual ( [
240+ {
241+ name : 'expo.modules.updates.EXPO_RUNTIME_VERSION' ,
242+ value : '@string/expo_runtime_version' ,
243+ } ,
244+ ] ) ;
245+ expect (
246+ extractStringResourcesFromResourcesXml (
247+ {
248+ resources : {
249+ string : [
250+ {
251+ $ : { name : 'expo_runtime_version' } ,
252+ _ : '2.0.0' ,
253+ } ,
254+ ] ,
255+ } ,
256+ } ,
257+ [ 'expo_runtime_version' ]
258+ )
259+ ) . toEqual ( [
260+ {
261+ name : 'expo_runtime_version' ,
262+ value : '2.0.0' ,
263+ } ,
264+ ] ) ;
265+ } ) ;
266+
127267 function createAndroidDir ( ) : string {
128268 const tempDirectory = fs . mkdtempSync (
129269 path . join ( os . tmpdir ( ) , 'react-native-brownfield-android-' )
0 commit comments