From 32e8fe8344667f7460284cdf240ab5e73cdb4fde Mon Sep 17 00:00:00 2001 From: Nicolas Bonamy Date: Fri, 10 May 2024 14:50:28 -0500 Subject: [PATCH] more tests --- tests/unit/shortcuts.test.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/unit/shortcuts.test.ts diff --git a/tests/unit/shortcuts.test.ts b/tests/unit/shortcuts.test.ts new file mode 100644 index 00000000..63be80dc --- /dev/null +++ b/tests/unit/shortcuts.test.ts @@ -0,0 +1,35 @@ + +import { expect, test } from 'vitest' +import { shortcutAccelerator } from '../../src/main/shortcuts' + +test('Shortcuts Keys', async () => { + expect(shortcutAccelerator(null)).toBeNull() + expect(shortcutAccelerator({key: 'Space'})).toBe('Space') + expect(shortcutAccelerator({key: 'A'})).toBe('A') + expect(shortcutAccelerator({key: '+'})).toBe('Plus') + expect(shortcutAccelerator({key: '↑'})).toBe('Up') + expect(shortcutAccelerator({key: '↓'})).toBe('Down') + expect(shortcutAccelerator({key: '←'})).toBe('Left') + expect(shortcutAccelerator({key: '→'})).toBe('Right') +}) + +test('Shortcuts Modifiers', async () => { + expect(shortcutAccelerator({key: 'A', alt: true})).toBe('Alt+A') + expect(shortcutAccelerator({key: 'A', ctrl: true})).toBe('Control+A') + expect(shortcutAccelerator({key: 'A', shift: true})).toBe('Shift+A') + expect(shortcutAccelerator({key: 'A', meta: true})).toBe('Command+A') + + expect(shortcutAccelerator({key: 'A', alt: true, ctrl: true})).toBe('Alt+Control+A') + expect(shortcutAccelerator({key: 'A', alt: true, shift: true})).toBe('Alt+Shift+A') + expect(shortcutAccelerator({key: 'A', alt: true, meta: true})).toBe('Alt+Command+A') + expect(shortcutAccelerator({key: 'A', ctrl: true, shift: true})).toBe('Control+Shift+A') + expect(shortcutAccelerator({key: 'A', ctrl: true, meta: true})).toBe('Control+Command+A') + expect(shortcutAccelerator({key: 'A', shift: true, meta: true})).toBe('Shift+Command+A') + + expect(shortcutAccelerator({key: 'A', alt: true, ctrl: true, shift: true})).toBe('Alt+Control+Shift+A') + expect(shortcutAccelerator({key: 'A', alt: true, ctrl: true, meta: true})).toBe('Alt+Control+Command+A') + expect(shortcutAccelerator({key: 'A', alt: true, shift: true, meta: true})).toBe('Alt+Shift+Command+A') + expect(shortcutAccelerator({key: 'A', ctrl: true, shift: true, meta: true})).toBe('Control+Shift+Command+A') + + expect(shortcutAccelerator({key: 'A', alt: true, ctrl: true, shift: true, meta: true})).toBe('Alt+Control+Shift+Command+A') +})