use anyhow::Result;
use arb_lib::{
deepl::{ApiOptions, DeeplApi, Lang},
ArbValue, Intl, TranslationOptions,
};
use serde_json::Value;
#[tokio::test]
pub async fn html_translate() -> Result<()> {
let api = DeeplApi::new(ApiOptions::new(&std::env::var("DEEPL_API_KEY").unwrap()));
let index = "tests/fixtures/html.yaml";
let mut intl = Intl::new(index)?;
let options = TranslationOptions::new(Lang::Fr);
let result = intl.translate(&api, options).await?;
// println!("{:#?}", result.translated);
let links = result.translated.lookup("links");
assert!(links.is_some());
let expected = Value::String("En créant un compte, vous acceptez notre politique de confidentialité, nos conditions d'utilisation et notre politique d'utilisation acceptable.".to_owned());
let expected_value: ArbValue<'_> = (&expected).into();
assert_eq!(&expected_value, links.unwrap().value());
Ok(())
}