mirror of
https://github.com/esphome/esphome.git
synced 2026-09-30 16:30:22 +00:00
[climate_ir] Store the supported modes in one mask (#19580)
This commit is contained in:
@@ -5,7 +5,8 @@ namespace esphome::climate_ir::testing {
|
||||
|
||||
class TestClimateIR : public ClimateIR {
|
||||
public:
|
||||
TestClimateIR() : ClimateIR(16.0f, 30.0f) {}
|
||||
explicit TestClimateIR(bool supports_dry = false, bool supports_fan_only = false)
|
||||
: ClimateIR(16.0f, 30.0f, 1.0f, supports_dry, supports_fan_only) {}
|
||||
|
||||
using ClimateIR::traits;
|
||||
|
||||
@@ -53,4 +54,30 @@ TEST(ClimateIRTest, HeatAndCoolModesFollowTheirOwnFlags) {
|
||||
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_OFF));
|
||||
}
|
||||
|
||||
TEST(ClimateIRTest, DefaultModes) {
|
||||
TestClimateIR climate;
|
||||
auto traits = climate.traits();
|
||||
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_OFF));
|
||||
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_COOL));
|
||||
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_HEAT));
|
||||
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_HEAT_COOL));
|
||||
EXPECT_FALSE(traits.supports_mode(climate::CLIMATE_MODE_DRY));
|
||||
EXPECT_FALSE(traits.supports_mode(climate::CLIMATE_MODE_FAN_ONLY));
|
||||
}
|
||||
|
||||
TEST(ClimateIRTest, DryAndFanOnlyFromConstructor) {
|
||||
TestClimateIR climate(true, true);
|
||||
auto traits = climate.traits();
|
||||
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_DRY));
|
||||
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_FAN_ONLY));
|
||||
}
|
||||
|
||||
TEST(ClimateIRTest, SetterCanTurnAModeBackOn) {
|
||||
TestClimateIR climate;
|
||||
climate.set_supports_cool(false);
|
||||
EXPECT_FALSE(climate.traits().supports_mode(climate::CLIMATE_MODE_COOL));
|
||||
climate.set_supports_cool(true);
|
||||
EXPECT_TRUE(climate.traits().supports_mode(climate::CLIMATE_MODE_COOL));
|
||||
}
|
||||
|
||||
} // namespace esphome::climate_ir::testing
|
||||
|
||||
Reference in New Issue
Block a user