File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ authors = ["Yesudeep Mangalapilly <yesudeep@google.com>"]
1919categories = [" development-tools" ]
2020description = " A smoke test package for dotprompt workspace."
2121edition = " 2024"
22- keywords = [" smoke-test " , " dotprompt " ]
22+ keywords = [" dotprompt " , " smoke-test " ]
2323license = " Apache-2.0"
2424name = " smoke"
2525readme = " README.md"
Original file line number Diff line number Diff line change 1515# SPDX-License-Identifier: Apache-2.0
1616
1717[formatting ]
18+ align_comments = true
1819align_entries = true
20+ array_auto_collapse = false
1921array_trailing_comma = true
2022reorder_keys = true
2123trailing_newline = true
You can’t perform that action at this time.
0 commit comments