Christopher Mullins лет назад: 6
Родитель
Сommit
895b5c0194
1 измененных файлов с 36 добавлено и 0 удалено
  1. 36 0
      test/remote/spec/state_spec.rb

+ 36 - 0
test/remote/spec/state_spec.rb

@@ -105,4 +105,40 @@ RSpec.describe 'State' do
     #   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