@@ -180,11 +180,33 @@ def test_hasPod_whenInstallerHasPod_returnTrue
180180 # ============================ #
181181 # Test - Exclude Architectures #
182182 # ============================ #
183- def test_excludeArchitectures_whenHermesEngineIsNotIncluded_excludeNothing
183+ def test_excludeArchitectures_whenHermesEngineIsNotIncluded_withNoValue_leaveUnset
184+ # Arrange
185+ user_project_mock = prepare_empty_user_project_mock ( )
186+ pods_projects_mock = PodsProjectMock . new ( )
187+ installer = InstallerMock . new ( PodsProjectMock . new ( ) , [
188+ AggregatedProjectMock . new ( user_project_mock )
189+ ] )
190+
191+ # Act
192+ ReactNativePodsUtils . exclude_i386_architecture_while_using_hermes ( installer )
193+
194+ # Assert
195+ user_project_mock . build_configurations . each do |config |
196+ assert_equal ( config . build_settings [ "EXCLUDED_ARCHS[sdk=iphonesimulator*]" ] , nil )
197+ end
198+ assert_equal ( user_project_mock . save_invocation_count , 0 )
199+ assert_equal ( pods_projects_mock . save_invocation_count , 0 )
200+ end
201+
202+ def test_excludeArchitectures_whenHermesEngineIsNotIncluded_withExistingValue_preserveExistingValue
184203 # Arrange
185204 user_project_mock = prepare_empty_user_project_mock ( )
205+ user_project_mock . build_configurations . each do |config |
206+ config . build_settings [ "EXCLUDED_ARCHS[sdk=iphonesimulator*]" ] = "arm64"
207+ end
186208 pods_projects_mock = PodsProjectMock . new ( )
187- installer = InstallerMock . new ( PodsProjectMock . new ( ) , [
209+ installer = InstallerMock . new ( pods_projects_mock , [
188210 AggregatedProjectMock . new ( user_project_mock )
189211 ] )
190212
@@ -193,13 +215,14 @@ def test_excludeArchitectures_whenHermesEngineIsNotIncluded_excludeNothing
193215
194216 # Assert
195217 user_project_mock . build_configurations . each do |config |
196- assert_equal ( config . build_settings [ "EXCLUDED_ARCHS[sdk=iphonesimulator*]" ] , "" )
218+ assert_equal ( config . build_settings [ "EXCLUDED_ARCHS[sdk=iphonesimulator*]" ] , "arm64 " )
197219 end
198- assert_equal ( user_project_mock . save_invocation_count , 1 )
220+
221+ assert_equal ( user_project_mock . save_invocation_count , 0 )
199222 assert_equal ( pods_projects_mock . save_invocation_count , 0 )
200223 end
201224
202- def test_excludeArchitectures_whenHermesEngineIsIncluded_excludeI386
225+ def test_excludeArchitectures_whenHermesEngineIsIncluded_withNoValue_onlyExcludeI386
203226 # Arrange
204227 user_project_mock = prepare_empty_user_project_mock ( )
205228 pods_projects_mock = PodsProjectMock . new ( [ ] , { "hermes-engine" => { } } )
@@ -219,6 +242,29 @@ def test_excludeArchitectures_whenHermesEngineIsIncluded_excludeI386
219242 assert_equal ( pods_projects_mock . save_invocation_count , 1 )
220243 end
221244
245+ def test_excludeArchitectures_whenHermesEngineIsIncluded_withExistingValue_appendI386
246+ # Arrange
247+ user_project_mock = prepare_empty_user_project_mock ( )
248+ user_project_mock . build_configurations . each do |config |
249+ config . build_settings [ "EXCLUDED_ARCHS[sdk=iphonesimulator*]" ] = "arm64"
250+ end
251+ pods_projects_mock = PodsProjectMock . new ( [ ] , { "hermes-engine" => { } } )
252+ installer = InstallerMock . new ( pods_projects_mock , [
253+ AggregatedProjectMock . new ( user_project_mock )
254+ ] )
255+
256+ # Act
257+ ReactNativePodsUtils . exclude_i386_architecture_while_using_hermes ( installer )
258+
259+ # Assert
260+ user_project_mock . build_configurations . each do |config |
261+ assert_equal ( config . build_settings [ "EXCLUDED_ARCHS[sdk=iphonesimulator*]" ] , "arm64 i386" )
262+ end
263+
264+ assert_equal ( user_project_mock . save_invocation_count , 1 )
265+ assert_equal ( pods_projects_mock . save_invocation_count , 1 )
266+ end
267+
222268 # ================= #
223269 # Test - Fix Config #
224270 # ================= #
0 commit comments