hotkeys: Rename adjust_mac_tooltip_keys to adjust_mac_hotkeys.

This commit is contained in:
Sayam Samal 2024-03-02 13:04:49 +05:30 committed by Tim Abbott
parent 4b0e6ae3d8
commit 36e709c934
3 changed files with 11 additions and 11 deletions

View File

@ -95,7 +95,7 @@ export function adjust_mac_kbd_tags(kbd_elem_class: string): void {
// We convert the hotkey hints used in the tooltips to mac equivalent // We convert the hotkey hints used in the tooltips to mac equivalent
// key combinations, when we detect that the user is using a mac-style keyboard. // key combinations, when we detect that the user is using a mac-style keyboard.
export function adjust_mac_tooltip_keys(hotkeys: string[]): void { export function adjust_mac_hotkey_hints(hotkeys: string[]): void {
if (!has_mac_keyboard()) { if (!has_mac_keyboard()) {
return; return;
} }

View File

@ -120,7 +120,7 @@ Handlebars.registerHelper("numberFormat", (number) => number.toLocaleString());
Handlebars.registerHelper("tooltip_hotkey_hints", (...hotkeys) => { Handlebars.registerHelper("tooltip_hotkey_hints", (...hotkeys) => {
hotkeys.pop(); // Handlebars options hotkeys.pop(); // Handlebars options
let hotkey_hints = ""; let hotkey_hints = "";
common.adjust_mac_tooltip_keys(hotkeys); common.adjust_mac_hotkey_hints(hotkeys);
for (const hotkey of hotkeys) { for (const hotkey of hotkeys) {
hotkey_hints += `<span class="tooltip-hotkey-hint">${hotkey}</span>`; hotkey_hints += `<span class="tooltip-hotkey-hint">${hotkey}</span>`;
} }

View File

@ -142,18 +142,18 @@ run_test("adjust_mac_kbd_tags mac", ({override}) => {
} }
}); });
run_test("adjust_mac_tooltip_keys non-mac", ({override}) => { run_test("adjust_mac_hotkey_hints non-mac", ({override}) => {
override(navigator, "platform", "Windows"); override(navigator, "platform", "Windows");
// The adjust_mac_tooltip_keys has a really simple guard // The adjust_mac_hotkey_hints has a really simple guard
// at the top, and we just test the early-return behavior // at the top, and we just test the early-return behavior
// by trying to pass it garbage. // by trying to pass it garbage.
common.adjust_mac_tooltip_keys("not-an-array"); common.adjust_mac_hotkey_hints("not-an-array");
}); });
// Test default values of adjust_mac_tooltip_keys // Test default values of adjust_mac_hotkey_hints
// Expected values // Expected values
run_test("adjust_mac_tooltip_keys mac expected", ({override}) => { run_test("adjust_mac_hotkey_hints mac expected", ({override}) => {
const keys_to_test_mac = new Map([ const keys_to_test_mac = new Map([
[["Backspace"], ["Delete"]], [["Backspace"], ["Delete"]],
[["Enter"], ["Return"]], [["Enter"], ["Return"]],
@ -170,7 +170,7 @@ run_test("adjust_mac_tooltip_keys mac expected", ({override}) => {
for (const [old_key, mac_key] of keys_to_test_mac) { for (const [old_key, mac_key] of keys_to_test_mac) {
const test_item = {}; const test_item = {};
common.adjust_mac_tooltip_keys(old_key); common.adjust_mac_hotkey_hints(old_key);
test_item.mac_key = mac_key; test_item.mac_key = mac_key;
test_item.adjusted_key = old_key; test_item.adjusted_key = old_key;
@ -182,9 +182,9 @@ run_test("adjust_mac_tooltip_keys mac expected", ({override}) => {
} }
}); });
// Test non-default values of adjust_mac_tooltip_keys // Test non-default values of adjust_mac_hotkey_hints
// Random values // Random values
run_test("adjust_mac_tooltip_keys mac random", ({override}) => { run_test("adjust_mac_hotkey_hints mac random", ({override}) => {
const keys_to_test_mac = new Map([ const keys_to_test_mac = new Map([
[ [
["Ctrl", "["], ["Ctrl", "["],
@ -207,7 +207,7 @@ run_test("adjust_mac_tooltip_keys mac random", ({override}) => {
for (const [old_key, mac_key] of keys_to_test_mac) { for (const [old_key, mac_key] of keys_to_test_mac) {
const test_item = {}; const test_item = {};
common.adjust_mac_tooltip_keys(old_key); common.adjust_mac_hotkey_hints(old_key);
test_item.mac_key = mac_key; test_item.mac_key = mac_key;
test_item.adjusted_key = old_key; test_item.adjusted_key = old_key;