Files
noteflow/client/src/api/adapters/tauri/utils.test.ts
2026-01-22 15:34:56 +00:00

33 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { IdentityDefaults } from '@/api/core/constants';
import { normalizeProjectId, normalizeProjectIds, recordingBlockedDetails, RECORDING_BLOCKED_PREFIX } from '@/api/adapters/tauri/utils';
describe('tauri utils', () => {
it('normalizes project ids', () => {
expect(normalizeProjectId()).toBeUndefined();
expect(normalizeProjectId(' ')).toBeUndefined();
expect(normalizeProjectId(IdentityDefaults.DEFAULT_PROJECT_ID)).toBeUndefined();
expect(normalizeProjectId(' custom ')).toBe('custom');
const ids = normalizeProjectIds([
' one ',
IdentityDefaults.DEFAULT_PROJECT_ID,
'',
'two',
]);
expect(ids).toEqual(['one', 'two']);
});
it('extracts recording blocked details', () => {
const message = `${RECORDING_BLOCKED_PREFIX}: rule_id=abc, rule_label=Focus, app_name=Zoom`;
const details = recordingBlockedDetails(message);
expect(details).toEqual({ ruleId: 'abc', ruleLabel: 'Focus', appName: 'Zoom' });
const errorDetails = recordingBlockedDetails(new Error(message));
expect(errorDetails?.ruleId).toBe('abc');
expect(recordingBlockedDetails('nope')).toBeNull();
});
});