文件
mynode/packages/lib/services/interop/Module.test.ts
chen 301194963b
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

54 行
2.2 KiB
TypeScript

import InteropService_Exporter_Base from './InteropService_Exporter_Base';
import InteropService_Importer_Base from './InteropService_Importer_Base';
import { makeExportModule, makeImportModule } from './Module';
import { ExportModuleOutputFormat, FileSystemItem } from './types';
describe('Module', () => {
it('should return correct default fullLabel for an ImportModule', () => {
const baseMetadata = {
format: 'Foo_test',
description: 'Some description here',
sources: [FileSystemItem.File, FileSystemItem.Directory],
};
const importModuleMultiSource = makeImportModule(
baseMetadata,
() => new InteropService_Importer_Base(),
);
const importModuleSingleSource = makeImportModule({
...baseMetadata,
sources: [FileSystemItem.File],
}, () => new InteropService_Importer_Base());
// The two modules should have the same data, except for their sources.
expect(importModuleMultiSource.format).toBe('Foo_test');
expect(importModuleSingleSource.format).toBe(importModuleMultiSource.format);
expect(importModuleMultiSource.sources).toHaveLength(2);
expect(importModuleSingleSource.sources).toHaveLength(1);
const baseLabel = 'FOO - Some description here';
expect(importModuleMultiSource.fullLabel()).toBe(baseLabel);
expect(importModuleSingleSource.fullLabel()).toBe(baseLabel);
// Should only include (File) if the import module has more than one source
expect(importModuleMultiSource.fullLabel(FileSystemItem.File)).toBe(`${baseLabel} (File)`);
expect(importModuleSingleSource.fullLabel(FileSystemItem.File)).toBe(baseLabel);
});
it('should return correct default fullLabel for an ExportModule', () => {
const testExportModule = makeExportModule({
format: 'format_test_______TEST' as ExportModuleOutputFormat,
description: 'Testing...',
}, () => new InteropService_Exporter_Base());
// Should only include the portion of format before the first underscore
const label = 'FORMAT - Testing...';
expect(testExportModule.fullLabel()).toBe(label);
// Sources should only be shown for import modules
expect(testExportModule.fullLabel(FileSystemItem.File)).toBe(label);
expect(testExportModule.fullLabel(FileSystemItem.Directory)).toBe(label);
});
});