test: backfill hotkeys helper tests

and remove support for the unused use case of comma-delimited-strings
This commit is contained in:
Mike Dalessio
2025-08-28 11:44:51 -04:00
parent 41edfae2b5
commit 28c4cc7cee
2 changed files with 62 additions and 15 deletions
+52
View File
@@ -0,0 +1,52 @@
require "test_helper"
class HotkeysHelperTest < ActionView::TestCase
include SetPlatform
test "mac modifier key" do
emulate_mac
assert_equal "⌘J", hotkey_label([ "", "J" ])
end
test "linux modifier key" do
emulate_linux
assert_equal "ctrlJ", hotkey_label([ "ctrl", "J" ])
end
test "mac enter" do
emulate_mac
assert_equal "returnJ", hotkey_label([ "enter", "J" ])
end
test "linux enter" do
emulate_linux
assert_equal "enterJ", hotkey_label([ "enter", "J" ])
end
test "mac hyper" do
emulate_mac
assert_equal "hyperJ", hotkey_label([ "hyper", "J" ])
end
test "linux hyper" do
emulate_linux
assert_equal "hyperJ", hotkey_label([ "hyper", "J" ])
end
private
def emulate_mac
stub_platform = ApplicationPlatform.new("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36")
self.stubs(:platform).returns(stub_platform)
end
def emulate_linux
stub_platform = ApplicationPlatform.new("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36")
self.stubs(:platform).returns(stub_platform)
end
end