UNPKG

@apistudio/apim-cli

Version:

CLI for API Management Products

41 lines (30 loc) 1.06 kB
/** * Copyright Super iPaaS Integration LLC, an IBM Company 2024 */ import {YamlValidator} from '../../src/validator/yaml.validator.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('YamlValidator', () => { let yamlValidator: YamlValidator; beforeEach(() => { yamlValidator = new YamlValidator(); }); it('should validate valid YAML files', async() => { const zipFilePath = path.resolve(__dirname, '../assets/valid-asset.zip'); const zipBuffer = fs.readFileSync(zipFilePath); const isValid = await yamlValidator.validateYamlFiles(zipBuffer); expect(isValid).toBe(true); }); it('should handle and invalidate invalid YAML files', async() => { const zipFilePath = path.resolve(__dirname, '../assets/invalid-yaml-asset.zip'); const zipBuffer = fs.readFileSync(zipFilePath); const isValid = await yamlValidator.validateYamlFiles(zipBuffer); expect(isValid).toBe(false); }); });