@@ -173,6 +173,59 @@ describe('readSwiftpmConfig', () => {
173173 warnSpy . mockRestore ( ) ;
174174 }
175175 } ) ;
176+
177+ it ( 'says nothing when swiftpmConfig mirrors every field of the spm block' , ( ) => {
178+ const warnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
179+ try {
180+ const settings = {
181+ name : 'RNSentry' ,
182+ dependencies : [ 'react-native-worklets' ] ,
183+ } ;
184+ const root = makeRoot ( { name : 'lib' , swiftpmConfig : settings } ) ;
185+ const config = readSwiftpmConfig ( root , {
186+ spm : { name : 'RNSentry' , dependencies : [ 'react-native-worklets' ] } ,
187+ } ) ;
188+ expect ( config ) . toEqual ( settings ) ;
189+ expect ( warnSpy ) . not . toHaveBeenCalled ( ) ;
190+ } finally {
191+ warnSpy . mockRestore ( ) ;
192+ }
193+ } ) ;
194+
195+ it ( 'still warns about a field the two places disagree on' , ( ) => {
196+ const warnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
197+ try {
198+ const root = makeRoot ( {
199+ name : 'lib' ,
200+ swiftpmConfig : { name : 'RNSVG' , dependencies : [ 'a' ] } ,
201+ } ) ;
202+ const config = readSwiftpmConfig ( root , {
203+ spm : { name : 'OldName' , dependencies : [ 'a' ] } ,
204+ } ) ;
205+ expect ( config ) . toEqual ( { name : 'RNSVG' , dependencies : [ 'a' ] } ) ;
206+ expect ( warnSpy ) . toHaveBeenCalledTimes ( 1 ) ;
207+ const message = warnSpy . mock . calls [ 0 ] . join ( ' ' ) ;
208+ expect ( message ) . toContain ( "deprecated 'spm' block (name)" ) ;
209+ } finally {
210+ warnSpy . mockRestore ( ) ;
211+ }
212+ } ) ;
213+
214+ it ( 'names only the fields the spm block alone declares' , ( ) => {
215+ const warnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
216+ try {
217+ const root = makeRoot ( { name : 'lib' , swiftpmConfig : { name : 'RNSVG' } } ) ;
218+ const config = readSwiftpmConfig ( root , {
219+ spm : { name : 'RNSVG' , dependencies : [ 'a' ] } ,
220+ } ) ;
221+ expect ( config ) . toEqual ( { name : 'RNSVG' , dependencies : [ 'a' ] } ) ;
222+ expect ( warnSpy ) . toHaveBeenCalledTimes ( 1 ) ;
223+ const message = warnSpy . mock . calls [ 0 ] . join ( ' ' ) ;
224+ expect ( message ) . toContain ( "deprecated 'spm' block (dependencies)" ) ;
225+ } finally {
226+ warnSpy . mockRestore ( ) ;
227+ }
228+ } ) ;
176229} ) ;
177230
178231describe ( 'readSwiftpmConfig (unknown keys)' , ( ) => {
0 commit comments