Skip to content

Commit

Permalink
adapter test (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonovk authored Nov 3, 2023
2 parents 824d1ec + 86e9dc9 commit 5b3c4b6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
31 changes: 31 additions & 0 deletions test/lib/xdotool/adapter_test.rb
Original file line number Diff line number Diff line change
@@ -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
16 changes: 9 additions & 7 deletions test/lib/xdotool/position_parse_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
require_relative '../lib/boaw'
require_relative '../lib/boaw/version'
require_relative '../lib/xdotool/position_parser'
require_relative '../lib/xdotool/adapter'

0 comments on commit 5b3c4b6

Please sign in to comment.