24 lines
1.0 KiB
TypeScript
24 lines
1.0 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { sourceFileLabel } from '../../src/shared/source-file-label';
|
|
|
|
describe('source file label', () => {
|
|
it('shows only the distinguishing part of a split report export', () => {
|
|
expect(sourceFileLabel(
|
|
'Security_Assessment_Report_sevenkingdoms.local_2026_07_22_08_23_22_(SI000157_CertificateTemplatesWithSANAllowed).csv'
|
|
)).toBe('SI000157_CertificateTemplatesWithSANAllowed');
|
|
expect(sourceFileLabel(
|
|
'Security_Assessment_Report_sevenkingdoms.local_2026_07_22_08_23_22_(Indicators_results).csv'
|
|
)).toBe('Indicators_results');
|
|
});
|
|
|
|
it('falls back to the name without extension when there is no part suffix', () => {
|
|
expect(sourceFileLabel('ad_hc_sevenkingdoms.local.html')).toBe('ad_hc_sevenkingdoms.local');
|
|
expect(sourceFileLabel('Maester.xlsx')).toBe('Maester');
|
|
});
|
|
|
|
it('handles missing or empty names without throwing', () => {
|
|
expect(sourceFileLabel(undefined)).toBe('');
|
|
expect(sourceFileLabel('')).toBe('');
|
|
});
|
|
});
|