fn test_matches_user_environment_all_locales()

in components/search/src/environment_matching.rs [145:296]


    fn test_matches_user_environment_all_locales() {
        assert!(
            matches_user_environment(
                &crate::JSONVariantEnvironment {
                    all_regions_and_locales: true,
                    excluded_locales: vec![],
                    excluded_regions: vec![],
                    locales: vec![],
                    regions: vec![],
                    ..Default::default()
                },
                &SearchUserEnvironment {
                    locale: "fi".into(),
                    region: "FR".into(),
                    ..Default::default()
                }
            ),
            "Should return true when all_regions_and_locales is true"
        );

        assert!(
            matches_user_environment(
                &crate::JSONVariantEnvironment {
                    all_regions_and_locales: false,
                    excluded_locales: vec![],
                    excluded_regions: vec![],
                    locales: vec![],
                    regions: vec![],
                    ..Default::default()
                },
                &SearchUserEnvironment {
                    locale: "fi".into(),
                    region: "fr".into(),
                    ..Default::default()
                }
            ),
            "Should return true when all_regions_and_locales is false (default) and no regions/locales are specified"
        );

        assert!(
            !matches_user_environment(
                &crate::JSONVariantEnvironment {
                    all_regions_and_locales: true,
                    excluded_locales: vec!["fi".to_string()],
                    excluded_regions: vec![],
                    locales: vec![],
                    regions: vec![],
                    ..Default::default()
                },
                &SearchUserEnvironment {
                    locale: "fi".into(),
                    region: "fr".into(),
                    ..Default::default()
                }
            ),
            "Should return false when all_regions_and_locales is true and the locale is excluded"
        );

        assert!(
            !matches_user_environment(
                &crate::JSONVariantEnvironment {
                    all_regions_and_locales: true,
                    excluded_locales: vec!["FI".to_string()],
                    excluded_regions: vec![],
                    locales: vec![],
                    regions: vec![],
                    ..Default::default()
                },
                &SearchUserEnvironment {
                    locale: "fi".into(),
                    region: "fr".into(),
                    ..Default::default()
                }
            ),
            "Should return false when all_regions_and_locales is true and the excluded locale is a different case"
        );

        assert!(
            matches_user_environment(
                &crate::JSONVariantEnvironment {
                    all_regions_and_locales: true,
                    excluded_locales: vec!["en-US".to_string()],
                    excluded_regions: vec![],
                    locales: vec![],
                    regions: vec![],
                    ..Default::default()
                },
                &SearchUserEnvironment {
                    locale: "fi".into(),
                    region: "fr".into(),
                    ..Default::default()
                }
            ),
            "Should return true when all_regions_and_locales is true and the locale is not excluded"
        );

        assert!(
            !matches_user_environment(
                &crate::JSONVariantEnvironment {
                    all_regions_and_locales: true,
                    excluded_regions: vec!["us".to_string(), "fr".to_string()],
                    locales: vec![],
                    regions: vec![],
                    ..Default::default()
                },
                &SearchUserEnvironment {
                    locale: "fi".into(),
                    region: "fr".into(),
                    ..Default::default()
                }
            ),
            "Should return false when all_regions_and_locales is true and the region is excluded"
        );

        assert!(
            !matches_user_environment(
                &crate::JSONVariantEnvironment {
                    all_regions_and_locales: true,
                    excluded_locales: vec![],
                    excluded_regions: vec!["US".to_string(), "FR".to_string()],
                    locales: vec![],
                    regions: vec![],
                    ..Default::default()
                },
                &SearchUserEnvironment {
                    locale: "fi".into(),
                    region: "fr".into(),
                    ..Default::default()
                }
            ),
            "Should return false when all_regions_and_locales is true and the excluded region is a different case"
        );

        assert!(
            matches_user_environment(
                &crate::JSONVariantEnvironment {
                    all_regions_and_locales: true,
                    excluded_locales: vec![],
                    excluded_regions: vec!["us".to_string()],
                    locales: vec![],
                    regions: vec![],
                    ..Default::default()
                },
                &SearchUserEnvironment {
                    locale: "fi".into(),
                    region: "fr".into(),
                    ..Default::default()
                }
            ),
            "Should return true when all_regions_and_locales is true and the region is not excluded"
        );
    }