forked from finos/architecture-as-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocument-loader.spec.ts
More file actions
57 lines (44 loc) · 1.47 KB
/
document-loader.spec.ts
File metadata and controls
57 lines (44 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { CALM_META_SCHEMA_DIRECTORY } from '../consts';
import { buildDocumentLoader, DocumentLoaderOptions } from './document-loader';
const mocks = vi.hoisted(() => {
return {
fsDocLoader: vi.fn(() => ({
initialise: vi.fn(),
loadMissingDocument: vi.fn()
})),
calmHubDocLoader: vi.fn(() => ({
initialise: vi.fn(),
loadMissingDocument: vi.fn()
}))
};
});
vi.mock('./file-system-document-loader', () => {
return {
FileSystemDocumentLoader: mocks.fsDocLoader
};
});
vi.mock('./calmhub-document-loader', () => {
return {
CalmHubDocumentLoader: mocks.calmHubDocLoader
};
});
describe('DocumentLoader', () => {
beforeEach(() => {
vi.clearAllMocks();
vi.resetModules();
});
it('should create a FileSystemDocumentLoader', () => {
const docLoaderOpts: DocumentLoaderOptions = {
schemaDirectoryPath: 'schemas'
};
buildDocumentLoader(docLoaderOpts);
expect(mocks.fsDocLoader).toHaveBeenCalledWith([CALM_META_SCHEMA_DIRECTORY, 'schemas'], false);
});
it('should create a CalmHubDocumentLoader when calmHubUrl is defined in loader options', () => {
const docLoaderOpts: DocumentLoaderOptions = {
calmHubUrl: 'https://example.com'
};
buildDocumentLoader(docLoaderOpts);
expect(mocks.calmHubDocLoader).toHaveBeenCalledWith('https://example.com', false);
});
});