Skip to content

Commit

Permalink
test: Test use of fluent functions in template
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Feb 16, 2023
1 parent 389639d commit 6f69fe8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/basic/fluent.tera
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ fluent(key="hello", name=en) }} {{ fluent(key="hello", lang="tr-TR", name=tr) }}
2 changes: 2 additions & 0 deletions data/basic/fluent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en: World
tr: Dünya
1 change: 1 addition & 0 deletions data/locales/en-US/test.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello = Hello { $name }!
1 change: 1 addition & 0 deletions data/locales/tr-TR/test.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello = Merhaba { $name }!
16 changes: 16 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ mod cli_tests {
let assert = cmd.arg("-t").arg("data/basic/basic.tera").arg("data/basic/basic.toml").assert();
assert.success().stdout(predicate::str::contains("Bob likes orange"));
}

#[cfg(feature = "fluent")]
#[test]
fn it_proccess_fluent_functions() {
let mut cmd = Command::cargo_bin(env!("CARGO_BIN_EXE_tera")).unwrap();
let assert = cmd
.arg("-l")
.arg("en-US")
.arg("--locales-path")
.arg("data/locales/")
.arg("-t")
.arg("data/basic/fluent.tera")
.arg("data/basic/fluent.yaml")
.assert();
assert.success().stdout(predicate::str::contains("Hello World! Merhaba Dünya!"));
}
}

#[cfg(test)]
Expand Down

0 comments on commit 6f69fe8

Please sign in to comment.