UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

41 lines 1.44 kB
import { OpenApiService } from './openapi-service.js'; import { createTestConfig } from '../../test/config/test-config.js'; const okResponse = { '200': { description: 'ok' } }; const buildDocument = () => ({ openapi: '3.0.0', info: { title: 'Test API', version: '7.4.0' }, paths: { '/alpha-only': { get: { responses: okResponse, 'x-stability-level': 'alpha', }, }, '/mixed': { get: { responses: okResponse, 'x-stability-level': 'alpha', }, post: { responses: okResponse, 'x-stability-level': 'beta', }, }, '/stable': { put: { responses: okResponse, }, }, }, }); test('removeAlphaOperations removes alpha operations and empty paths', () => { const openApiService = new OpenApiService(createTestConfig()); const removeAlphaOperations = openApiService.removeAlphaOperations.bind(openApiService); const doc = buildDocument(); const filtered = removeAlphaOperations(doc); expect(filtered.paths?.['/alpha-only']).toBeUndefined(); expect(filtered.paths?.['/mixed']?.get).toBeUndefined(); expect(filtered.paths?.['/mixed']?.post).toBeDefined(); expect(filtered.paths?.['/stable']).toBeDefined(); }); //# sourceMappingURL=openapi-service.test.js.map