UNPKG

@apistudio/apim-cli

Version:

CLI for API Management Products

44 lines (40 loc) 1.37 kB
/** * Copyright Super iPaaS Integration LLC, an IBM Company 2024 */ import {AssetParser} from '../../src/parsers/asset.parser.js'; import path from 'path'; import fs from 'fs'; jest.mock('../../src/service/log-wrapper.ts'); jest.mock('@apic/studio-logger', ()=> ({ LoggerConfig: { isLoggerEnabled: jest.fn(), }, })); describe('AssetParser', () => { it('should create asset reference map with all values as true', async() => { const zipFilePath = path.resolve(__dirname, '../assets/valid-asset.zip'); const zipBuffer = fs.readFileSync(zipFilePath); const obj = new AssetParser(); const refmap =await obj.createAssetReferenceMap(zipBuffer); await obj.updateMapWithGatewayEndpoints(zipBuffer,refmap); refmap.forEach((value, key) => { expect(value).toBe(true); }); }); it('should create asset reference map with all values not as true', async() => { const zipFilePath = path.resolve(__dirname, '../assets/invalid-asset.zip'); const zipBuffer = fs.readFileSync(zipFilePath); const obj = new AssetParser(); const refmap =await obj.createAssetReferenceMap(zipBuffer); await obj.updateMapWithGatewayEndpoints(zipBuffer,refmap); let hasFalseValue = false; refmap.forEach((value, key) => { if (value === false) { hasFalseValue = true; } else { expect(value).toBe(true); } }); expect(hasFalseValue).toBe(true); }); });