diff --git a/test/lib/xdotool/adapter_test.rb b/test/lib/xdotool/adapter_test.rb new file mode 100644 index 0000000..d7d96dc --- /dev/null +++ b/test/lib/xdotool/adapter_test.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'minitest/autorun' +require_relative '../../test_helper' + +module Xdotool + class AdapterTest < Minitest::Test + def setup + @position = { x: 1, y: 2 } + @adapter = Adapter.new + end + + def test_left_click + mock_kernel = Minitest::Mock.new + mock_kernel.expect(:system, nil, ['xdotool mousemove 1 2 click 1']) + Kernel.stub :system, ->(a) { mock_kernel.system(a) } do + @adapter.left_click(@position) + end + mock_kernel.verify + end + + def test_right_click + mock_kernel = Minitest::Mock.new + mock_kernel.expect(:system, nil, ['xdotool mousemove 1 2 click 3']) + Kernel.stub :system, ->(a) { mock_kernel.system(a) } do + @adapter.right_click(@position) + end + mock_kernel.verify + end + end +end diff --git a/test/lib/xdotool/position_parse_test.rb b/test/lib/xdotool/position_parse_test.rb index 28a19e3..135b5d2 100644 --- a/test/lib/xdotool/position_parse_test.rb +++ b/test/lib/xdotool/position_parse_test.rb @@ -3,13 +3,15 @@ require 'minitest/autorun' require_relative '../../test_helper' -class PositionParserTest < Minitest::Test - def setup - @position = 'x:761 y:1051 screen:0 window:20971523' - @expect_result = { x: 761, y: 1051 } - end +module Xdotool + class PositionParserTest < Minitest::Test + def setup + @position = 'x:761 y:1051 screen:0 window:20971523' + @expect_result = { x: 761, y: 1051 } + end - def test_version - assert_equal @expect_result, Xdotool::PositionParser.parse(@position) + def test_parser + assert_equal @expect_result, PositionParser.parse(@position) + end end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 9c21673..f6f91df 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,3 +3,4 @@ require_relative '../lib/boaw' require_relative '../lib/boaw/version' require_relative '../lib/xdotool/position_parser' +require_relative '../lib/xdotool/adapter'