50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
const { resolveCommand } = require('../electron/mac-agent');
|
|
|
|
describe('resolveCommand', () => {
|
|
test('bekannter Shortcut → applescript', () => {
|
|
expect(resolveCommand('spotify_play')).toEqual({
|
|
type: 'applescript',
|
|
script: 'tell application "Spotify" to play',
|
|
});
|
|
});
|
|
|
|
test('script: Präfix → applescript mit direktem Script', () => {
|
|
expect(resolveCommand('script:tell application "Finder" to activate')).toEqual({
|
|
type: 'applescript',
|
|
script: 'tell application "Finder" to activate',
|
|
});
|
|
});
|
|
|
|
test('open: Präfix → URL öffnen', () => {
|
|
expect(resolveCommand('open:https://example.com')).toEqual({
|
|
type: 'open',
|
|
url: 'https://example.com',
|
|
});
|
|
});
|
|
|
|
test('app: Präfix → App öffnen', () => {
|
|
expect(resolveCommand('app:Spotify')).toEqual({
|
|
type: 'app',
|
|
name: 'Spotify',
|
|
});
|
|
});
|
|
|
|
test('save: Präfix → Datei auf Desktop speichern', () => {
|
|
expect(resolveCommand('save:{"filename":"test.txt","content":"hallo"}')).toEqual({
|
|
type: 'save',
|
|
filename: 'test.txt',
|
|
content: 'hallo',
|
|
});
|
|
});
|
|
|
|
test('unbekannter Befehl → unknown', () => {
|
|
expect(resolveCommand('gibts_nicht')).toEqual({ type: 'unknown' });
|
|
});
|
|
|
|
test('volume_up ist bekannter Shortcut', () => {
|
|
const result = resolveCommand('volume_up');
|
|
expect(result.type).toBe('applescript');
|
|
expect(result.script).toContain('output volume');
|
|
});
|
|
});
|