Skip to content

Commit

Permalink
chore: Better name
Browse files Browse the repository at this point in the history
  • Loading branch information
tofumatt committed May 3, 2018
1 parent e6e1e7b commit c62cd5f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
7 changes: 3 additions & 4 deletions edit-post/keyboard-shortcuts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/**
* Internal dependencies
*/
import { tertiaryKeyCode, tertiaryShortcut } from 'utils/keycodes';
import { secondaryKeyCode, secondaryShortcut } from 'utils/keycodes';

console.log(tertiaryKeyCode( 'm' ));
export default {
toggleEditorMode: {
value: tertiaryKeyCode( 'm' ),
label: tertiaryShortcut( 'M' ),
value: secondaryKeyCode( 'm' ),
label: secondaryShortcut( 'M' ),
},
};
6 changes: 3 additions & 3 deletions utils/keycodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ export function primaryShortcut( character, _isMacOS = isMacOS ) {
*
* @return {string} The keyboard shortcut.
*/
export function tertiaryShortcut( character, _isMacOS = isMacOS ) {
return keyboardShortcut( tertiaryKeyCode( character.toUpperCase(), _isMacOS ), _isMacOS );
export function secondaryShortcut( character, _isMacOS = isMacOS ) {
return keyboardShortcut( secondaryKeyCode( character.toUpperCase(), _isMacOS ), _isMacOS );
}

export function tertiaryKeyCode( character, _isMacOS = isMacOS ) {
export function secondaryKeyCode( character, _isMacOS = isMacOS ) {
const keyCombo = _isMacOS() ? `${ SHIFT }+${ ALT }+${ PRIMARY }` : `${ PRIMARY }+${ SHIFT }+${ ALT }`;
return `${ keyCombo }+${ character }`;
}
18 changes: 9 additions & 9 deletions utils/test/keycodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
isMacOS,
keyboardShortcut,
primaryShortcut,
tertiaryKeyCode,
tertiaryShortcut,
secondaryKeyCode,
secondaryShortcut,
} from '../keycodes';

const isMacOSFalse = () => false;
Expand Down Expand Up @@ -131,30 +131,30 @@ describe( 'primaryShortcut', () => {
} );
} );

describe( 'tertiaryShortcut', () => {
describe( 'secondaryShortcut', () => {
it( 'should uppercase character', () => {
const shortcut = tertiaryShortcut( 'm', isMacOSFalse );
const shortcut = secondaryShortcut( 'm', isMacOSFalse );
expect( shortcut ).toEqual( 'Ctrl+Shift+Alt+M' );
} );

it( 'should output Shift+Alt text on Windows', () => {
const shortcut = tertiaryShortcut( 'M', isMacOSFalse );
const shortcut = secondaryShortcut( 'M', isMacOSFalse );
expect( shortcut ).toEqual( 'Ctrl+Shift+Alt+M' );
} );

it( 'should output control+option symbols on MacOS', () => {
const shortcut = tertiaryShortcut( 'M', isMacOSTrue );
const shortcut = secondaryShortcut( 'M', isMacOSTrue );
expect( shortcut ).toEqual( '⇧⌥⌘M' );
} );
} );

describe( 'tertiaryKeyCode', () => {
describe( 'secondaryKeyCode', () => {
it( 'outputs the correct keycode on MacOS', () => {
expect( tertiaryKeyCode( 'm', isMacOSTrue ) ).toEqual( 'shift+alt+mod+m' );
expect( secondaryKeyCode( 'm', isMacOSTrue ) ).toEqual( 'shift+alt+mod+m' );
} );

it( 'outputs the correct keycode on Windows', () => {
expect( tertiaryKeyCode( 'm', isMacOSFalse ) ).toEqual( 'mod+shift+alt+m' );
expect( secondaryKeyCode( 'm', isMacOSFalse ) ).toEqual( 'mod+shift+alt+m' );
} );
} );

Expand Down

0 comments on commit c62cd5f

Please sign in to comment.