浏览代码

add test for toggle

Christopher Mullins 6 年之前
父节点
当前提交
12f8159762
共有 1 个文件被更改,包括 18 次插入0 次删除
  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
   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
   context 'persistence' do
     it 'should persist parameters' do
     it 'should persist parameters' do
       desired_state = {
       desired_state = {