Skip to content

Commit

Permalink
add test for color command
Browse files Browse the repository at this point in the history
  • Loading branch information
sidoh committed Mar 31, 2019
1 parent 9798e2c commit 895b5c0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/remote/spec/state_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,40 @@
# expect(patched_state.select { |x| desired_state.include?(x) } ).to eq(desired_state)
# end
end

context 'fields' do
it 'should support the color field' do
desired_state = {
'hue' => 0,
'saturation' => 100,
'status' => 'ON'
}

@client.patch_state(
desired_state.merge(hue: 100),
@id_params
)

@client.patch_state(
{ color: '255,0,0' },
@id_params
)

state = @client.get_state(@id_params)

expect(state.keys).to include(*desired_state.keys)
expect(state.select { |x| desired_state.include?(x) } ).to eq(desired_state)

@client.patch_state(
{ color: {r: 0, g: 255, b: 0} },
@id_params
)
state = @client.get_state(@id_params)

desired_state.merge!('hue' => 120)

expect(state.keys).to include(*desired_state.keys)
expect(state.select { |x| desired_state.include?(x) } ).to eq(desired_state)
end
end
end

0 comments on commit 895b5c0

Please sign in to comment.