1313require_relative "./test_utils/FileMock.rb"
1414require_relative "./test_utils/systemUtils.rb"
1515require_relative "./test_utils/PathnameMock.rb"
16+ require_relative "./test_utils/TargetDefinitionMock.rb"
1617
1718class UtilsTests < Test ::Unit ::TestCase
1819 def setup
@@ -30,6 +31,7 @@ def teardown
3031 Environment . reset ( )
3132 ENV [ 'RCT_NEW_ARCH_ENABLED' ] = '0'
3233 ENV [ 'USE_HERMES' ] = '1'
34+ ENV [ 'USE_FRAMEWORKS' ] = nil
3335 system_reset_commands
3436 end
3537
@@ -481,6 +483,57 @@ def test_createXcodeEnvIfMissing_whenItIsNotPresent_createsIt
481483 assert_equal ( File . exist_invocation_params , [ "/.xcode.env" ] )
482484 assert_equal ( $collected_commands, [ "echo 'export NODE_BINARY=$(command -v node)' > /.xcode.env" ] )
483485 end
486+
487+ # ============================ #
488+ # Test - Detect Use Frameworks #
489+ # ============================ #
490+ def test_detectUseFrameworks_whenEnvAlreadySet_DoesNothing
491+ # Arrange
492+ ENV [ 'USE_FRAMEWORKS' ] = 'static'
493+ target_definition = TargetDefinitionMock . new ( 'something' )
494+
495+ # Act
496+ ReactNativePodsUtils . detect_use_frameworks ( target_definition )
497+
498+ # Assert
499+ assert_equal ( Pod ::UI . collected_messages , [ ] )
500+ end
501+
502+ def test_detectUseFrameworks_whenEnvNotSetAndNotUsed_setEnvVarToNil
503+ # Arrange
504+ target_definition = TargetDefinitionMock . new ( 'static library' )
505+
506+ # Act
507+ ReactNativePodsUtils . detect_use_frameworks ( target_definition )
508+
509+ # Assert
510+ assert_equal ( Pod ::UI . collected_messages , [ "Framework build type is static library" ] )
511+ assert_nil ( ENV [ 'USE_FRAMEWORKS' ] )
512+ end
513+
514+ def test_detectUseFrameworks_whenEnvNotSetAndStaticFrameworks_setEnvVarToStatic
515+ # Arrange
516+ target_definition = TargetDefinitionMock . new ( 'static framework' )
517+
518+ # Act
519+ ReactNativePodsUtils . detect_use_frameworks ( target_definition )
520+
521+ # Assert
522+ assert_equal ( Pod ::UI . collected_messages , [ "Framework build type is static framework" ] )
523+ assert_equal ( ENV [ 'USE_FRAMEWORKS' ] , 'static' )
524+ end
525+
526+ def test_detectUseFrameworks_whenEnvNotSetAndDynamicFrameworks_setEnvVarToDynamic
527+ # Arrange
528+ target_definition = TargetDefinitionMock . new ( 'dynamic framework' )
529+
530+ # Act
531+ ReactNativePodsUtils . detect_use_frameworks ( target_definition )
532+
533+ # Assert
534+ assert_equal ( Pod ::UI . collected_messages , [ "Framework build type is dynamic framework" ] )
535+ assert_equal ( ENV [ 'USE_FRAMEWORKS' ] , 'dynamic' )
536+ end
484537end
485538
486539def prepare_empty_user_project_mock
0 commit comments