Kaynağa Gözat

add test for toggle

Christopher Mullins 6 yıl önce
ebeveyn
işleme
12f8159762
1 değiştirilmiş dosya ile 18 ekleme ve 0 silme
  1. 18 0
      test/remote/spec/state_spec.rb

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

@@ -14,6 +14,24 @@ RSpec.describe 'State' do
     }
   end
 
+  context 'toggle command' do
+    it 'should toggle ON to OFF' do
+      init_state = @client.patch_state({'status' => 'ON'}, @id_params)
+      expect(init_state['status']).to eq('ON')
+
+      next_state = @client.patch_state({'command' => 'toggle'}, @id_params)
+      expect(next_state['status']).to eq('OFF')
+    end
+
+    it 'should toggle OFF to ON' do
+      init_state = @client.patch_state({'status' => 'OFF'}, @id_params)
+      expect(init_state['status']).to eq('OFF')
+
+      next_state = @client.patch_state({'command' => 'toggle'}, @id_params)
+      expect(next_state['status']).to eq('ON')
+    end
+  end
+
   context 'persistence' do
     it 'should persist parameters' do
       desired_state = {