Skip to content

Commit

Permalink
Add test for color_mode field
Browse files Browse the repository at this point in the history
  • Loading branch information
sidoh committed Sep 10, 2023
1 parent 6116d1b commit 076c292
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/remote/spec/state_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -563,4 +563,38 @@
expect(state['status']).to eq('ON')
end
end

context 'color_mode field' do
before(:all) do
@client.patch_settings({
group_state_fields: [
"status",
"level",
"kelvin",
"hue",
"saturation",
"color_mode",
"hex_color"
]
})
end

context 'for rgb+ww lights' do
it 'when in color mode, field should be "rgb" and color fields should be present' do
state = @client.patch_state({status: 'ON', color: '#ff0000'}, @id_params)

expect(state['color_mode']).to eq('rgb')
expect(state['hue']).to eq(0)
expect(state['saturation']).to eq(100)
expect(state['color']).to eq('#FF0000')
end

it 'when in white mode, field should be "color_temp" and color fields should not be present' do
state = @client.patch_state({status: 'ON', kelvin: 100, level: 100}, @id_params)

expect(state['color_mode']).to eq('color_temp')
expect(state['kelvin']).to eq(100)
end
end
end
end

0 comments on commit 076c292

Please sign in to comment.