mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	[template/text] Fix lambda config (#6655)
Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com>
This commit is contained in:
		| @@ -54,3 +54,17 @@ def test_text_config_value_mode_set(generate_main): | ||||
|     # Then | ||||
|     assert "it_1->traits.set_mode(text::TEXT_MODE_TEXT);" in main_cpp | ||||
|     assert "it_3->traits.set_mode(text::TEXT_MODE_PASSWORD);" in main_cpp | ||||
|  | ||||
|  | ||||
| def test_text_config_lamda_is_set(generate_main): | ||||
|     """ | ||||
|     Test if lambda is set for lambda mode | ||||
|     """ | ||||
|     # Given | ||||
|  | ||||
|     # When | ||||
|     main_cpp = generate_main("tests/component_tests/text/test_text.yaml") | ||||
|  | ||||
|     # Then | ||||
|     assert "it_4->set_template([=]() -> optional<std::string> {" in main_cpp | ||||
|     assert 'return std::string{"Hello"};' in main_cpp | ||||
|   | ||||
| @@ -31,3 +31,15 @@ text: | ||||
|     optimistic: true | ||||
|     internal: true | ||||
|     max_length: 255 | ||||
|  | ||||
|   - platform: template | ||||
|     name: "test 4 key" | ||||
|     id: "it_4" | ||||
|     mode: text | ||||
|     set_action: | ||||
|       - then: | ||||
|           - logger.log: | ||||
|               format: Template text set to %s | ||||
|               args: ["x.c_str()"] | ||||
|     lambda: | | ||||
|       return std::string{"Hello"}; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user