@@ -94,15 +94,15 @@ test('insertIos(): success', async () => {
9494 )
9595} )
9696
97- test ( 'insertIos(): success (swift)' , async ( ) => {
97+ test ( 'insertIos(): success (swift 0.78 )' , async ( ) => {
9898 type readdir = ( path : string ) => Promise < string [ ] >
9999 const readdirMock = fs . readdir as unknown as jest . MockedFunction < readdir >
100100
101101 readdirMock
102102 . mockResolvedValueOnce ( [ 'BugsnagReactNativeCliTest.xcodeproj' ] )
103103 . mockResolvedValueOnce ( [ 'a' , 'b' , 'AppDelegate.swift' , 'c' , 'd' ] )
104104
105- const appDelegate = await loadFixture ( path . join ( __dirname , 'fixtures' , 'AppDelegate-before.swift' ) )
105+ const appDelegate = await loadFixture ( path . join ( __dirname , 'fixtures' , 'AppDelegate-before-078 .swift' ) )
106106 const readFileMock = fs . readFile as jest . MockedFunction < typeof fs . readFile >
107107 readFileMock . mockResolvedValue ( appDelegate )
108108
@@ -113,7 +113,31 @@ test('insertIos(): success (swift)', async () => {
113113 expect ( readFileMock ) . toHaveBeenCalledWith ( '/random/path/ios/BugsnagReactNativeCliTest/AppDelegate.swift' , 'utf8' )
114114 expect ( writeFileMock ) . toHaveBeenCalledWith (
115115 '/random/path/ios/BugsnagReactNativeCliTest/AppDelegate.swift' ,
116- await loadFixture ( path . join ( __dirname , 'fixtures' , 'AppDelegate-after.swift' ) ) ,
116+ await loadFixture ( path . join ( __dirname , 'fixtures' , 'AppDelegate-after-078.swift' ) ) ,
117+ 'utf8'
118+ )
119+ } )
120+
121+ test ( 'insertIos(): success (swift 0.79+)' , async ( ) => {
122+ type readdir = ( path : string ) => Promise < string [ ] >
123+ const readdirMock = fs . readdir as unknown as jest . MockedFunction < readdir >
124+
125+ readdirMock
126+ . mockResolvedValueOnce ( [ 'BugsnagReactNativeCliTest.xcodeproj' ] )
127+ . mockResolvedValueOnce ( [ 'a' , 'b' , 'AppDelegate.swift' , 'c' , 'd' ] )
128+
129+ const appDelegate = await loadFixture ( path . join ( __dirname , 'fixtures' , 'AppDelegate-before-079.swift' ) )
130+ const readFileMock = fs . readFile as jest . MockedFunction < typeof fs . readFile >
131+ readFileMock . mockResolvedValue ( appDelegate )
132+
133+ const writeFileMock = fs . writeFile as jest . MockedFunction < typeof fs . writeFile >
134+ writeFileMock . mockResolvedValue ( )
135+
136+ await insertIos ( '/random/path' , logger )
137+ expect ( readFileMock ) . toHaveBeenCalledWith ( '/random/path/ios/BugsnagReactNativeCliTest/AppDelegate.swift' , 'utf8' )
138+ expect ( writeFileMock ) . toHaveBeenCalledWith (
139+ '/random/path/ios/BugsnagReactNativeCliTest/AppDelegate.swift' ,
140+ await loadFixture ( path . join ( __dirname , 'fixtures' , 'AppDelegate-after-079.swift' ) ) ,
117141 'utf8'
118142 )
119143} )
@@ -140,15 +164,37 @@ test('insertIos(): already present', async () => {
140164 expect ( logger . warn ) . toHaveBeenCalledWith ( 'Bugsnag is already included, skipping' )
141165} )
142166
143- test ( 'insertIos(): already present (swift)' , async ( ) => {
167+ test ( 'insertIos(): already present (swift 0.78)' , async ( ) => {
168+ type readdir = ( path : string ) => Promise < string [ ] >
169+ const readdirMock = fs . readdir as unknown as jest . MockedFunction < readdir >
170+
171+ readdirMock
172+ . mockResolvedValueOnce ( [ 'BugsnagReactNativeCliTest.xcodeproj' ] )
173+ . mockResolvedValueOnce ( [ 'a' , 'b' , 'AppDelegate.swift' , 'c' , 'd' ] )
174+
175+ const appDelegate = await loadFixture ( path . join ( __dirname , 'fixtures' , 'AppDelegate-after-078.swift' ) )
176+ const readFileMock = fs . readFile as jest . MockedFunction < typeof fs . readFile >
177+ readFileMock . mockResolvedValue ( appDelegate )
178+
179+ const writeFileMock = fs . writeFile as jest . MockedFunction < typeof fs . writeFile >
180+ writeFileMock . mockResolvedValue ( )
181+
182+ await insertIos ( '/random/path' , logger )
183+ expect ( readFileMock ) . toHaveBeenCalledWith ( '/random/path/ios/BugsnagReactNativeCliTest/AppDelegate.swift' , 'utf8' )
184+ expect ( writeFileMock ) . not . toHaveBeenCalled ( )
185+
186+ expect ( logger . warn ) . toHaveBeenCalledWith ( 'Bugsnag is already included, skipping' )
187+ } )
188+
189+ test ( 'insertIos(): already present (swift 0.79+)' , async ( ) => {
144190 type readdir = ( path : string ) => Promise < string [ ] >
145191 const readdirMock = fs . readdir as unknown as jest . MockedFunction < readdir >
146192
147193 readdirMock
148194 . mockResolvedValueOnce ( [ 'BugsnagReactNativeCliTest.xcodeproj' ] )
149195 . mockResolvedValueOnce ( [ 'a' , 'b' , 'AppDelegate.swift' , 'c' , 'd' ] )
150196
151- const appDelegate = await loadFixture ( path . join ( __dirname , 'fixtures' , 'AppDelegate-after.swift' ) )
197+ const appDelegate = await loadFixture ( path . join ( __dirname , 'fixtures' , 'AppDelegate-after-079 .swift' ) )
152198 const readFileMock = fs . readFile as jest . MockedFunction < typeof fs . readFile >
153199 readFileMock . mockResolvedValue ( appDelegate )
154200
0 commit comments