Skip to content

Commit 731c75b

Browse files
authored
test(py/handlebarrz): add test case for main block case with missing else block in ifEquals and unlessEquals helpers (#290)
1 parent 0df9f4b commit 731c75b

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

python/handlebarrz/src/helpers.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ mod if_equals_tests {
9090
);
9191
}
9292

93+
#[test]
94+
fn with_true_condition_renders_main_block_without_else_block() {
95+
let mut handlebars = Handlebars::new();
96+
handlebars.register_helper("ifEquals", Box::new(IfEqualsHelper {}));
97+
98+
assert_eq!(
99+
handlebars
100+
.render_template("{{#ifEquals 1 1}}yes{{/ifEquals}}", &json!({}))
101+
.unwrap(),
102+
"yes"
103+
);
104+
}
105+
93106
#[test]
94107
fn with_false_condition_renders_else_block() {
95108
let mut handlebars = Handlebars::new();
@@ -116,6 +129,7 @@ mod if_equals_tests {
116129
);
117130
}
118131
}
132+
119133
/// Helper for comparing inequality between two values.
120134
///
121135
/// Renders the template block if `arg1` is not equal to `arg2`.
@@ -190,6 +204,19 @@ mod unless_equals_tests {
190204
);
191205
}
192206

207+
#[test]
208+
fn with_false_condition_renders_main_block_without_else_block() {
209+
let mut handlebars = Handlebars::new();
210+
handlebars.register_helper("unlessEquals", Box::new(UnlessEqualsHelper {}));
211+
212+
assert_eq!(
213+
handlebars
214+
.render_template("{{#unlessEquals 1 2}}yes{{/unlessEquals}}", &json!({}))
215+
.unwrap(),
216+
"yes"
217+
);
218+
}
219+
193220
#[test]
194221
fn with_true_condition_renders_else_block() {
195222
let mut handlebars = Handlebars::new();
@@ -219,6 +246,7 @@ mod unless_equals_tests {
219246
);
220247
}
221248
}
249+
222250
/// Helper to serialize data to a JSON string.
223251
///
224252
/// ## Usage

rs/smoke/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ authors = ["Yesudeep Mangalapilly <yesudeep@google.com>"]
1919
categories = ["development-tools"]
2020
description = "A smoke test package for dotprompt workspace."
2121
edition = "2024"
22-
keywords = ["smoke-test", "dotprompt"]
22+
keywords = ["dotprompt", "smoke-test"]
2323
license = "Apache-2.0"
2424
name = "smoke"
2525
readme = "README.md"

taplo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
# SPDX-License-Identifier: Apache-2.0
1616

1717
[formatting]
18+
align_comments = true
1819
align_entries = true
20+
array_auto_collapse = false
1921
array_trailing_comma = true
2022
reorder_keys = true
2123
trailing_newline = true

0 commit comments

Comments
 (0)