use growthbook_rust::client::{GrowthBookClientBuilder, GrowthBookClientTrait};
use growthbook_rust::model_public::GrowthBookAttribute;
use serde_json::json;
#[tokio::test]
async fn case_insensitive_fold_is_unicode_aware_like_js() {
let features_json = json!({
"fold-dotted-i": {
"defaultValue": false,
"rules": [{ "condition": { "x": { "$ini": ["İ"] } }, "force": true }]
},
"fold-sharp-s": {
"defaultValue": false,
"rules": [{ "condition": { "x": { "$ini": ["STRAßE"] } }, "force": true }]
},
"fold-sigma": {
"defaultValue": false,
"rules": [{ "condition": { "x": { "$ini": ["Σ"] } }, "force": true }]
},
"fold-cyrillic": {
"defaultValue": false,
"rules": [{ "condition": { "x": { "$ini": ["А"] } }, "force": true }]
}
});
let client = GrowthBookClientBuilder::new().features_json(features_json).unwrap().build().await.expect("Failed to build client");
let attr = |value: &str| GrowthBookAttribute::from(json!({ "x": value })).unwrap();
assert!(!client.is_on("fold-dotted-i", Some(attr("i"))), "İ must not fold to i");
assert!(!client.is_on("fold-sharp-s", Some(attr("STRASSE"))), "ß must not expand to ss");
assert!(client.is_on("fold-sigma", Some(attr("σ"))), "Σ must fold to σ");
assert!(client.is_on("fold-cyrillic", Some(attr("а"))), "Cyrillic А must fold to а");
}