UNPKG

fume-fhir-converter

Version:

FHIR-Utilized Mapping Engine - Community

49 lines 1.91 kB
"use strict"; /** * © Copyright Outburn Ltd. 2022-2024 All Rights Reserved * Project name: FUME-COMMUNITY */ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const globals_1 = require("@jest/globals"); const fs = tslib_1.__importStar(require("fs")); const os_1 = tslib_1.__importDefault(require("os")); const path_1 = tslib_1.__importDefault(require("path")); const loadFhirPackageIndex_1 = require("./loadFhirPackageIndex"); jest.mock('fs'); describe('loadFhirPackageIndex', () => { afterEach(() => { jest.resetAllMocks(); }); globals_1.test.skip('Creates the cache folder if it does not exist', async () => { let counter = 0; fs.existsSync.mockImplementation((name) => { if (name.includes('fhirPackageIndex.json')) { return false; } if (counter === 0) { counter++; return false; } return true; }); fs.mkdirSync.mockReturnValue(true); fs.readdirSync.mockReturnValue([]); await (0, loadFhirPackageIndex_1.loadFhirPackageIndex)(); expect(fs.mkdirSync).toHaveBeenCalledTimes(1); expect(fs.mkdirSync).toHaveBeenCalledWith(path_1.default.join(os_1.default.homedir(), '.fhir', 'packages'), { recursive: true }); }); globals_1.test.skip('Doesnt create the cache folder if it exists', async () => { fs.existsSync.mockImplementation((name) => { if (name.includes('fhirPackageIndex.json')) { return false; } return true; }); fs.mkdirSync.mockReturnValue(true); fs.readdirSync.mockReturnValue([]); await (0, loadFhirPackageIndex_1.loadFhirPackageIndex)(); expect(fs.mkdirSync).toHaveBeenCalledTimes(0); }); }); //# sourceMappingURL=loadFhirPackageIndex.test.js.map