UNPKG

unleash-server

Version:

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

36 lines 1.25 kB
import { EXCEEDS_LIMIT } from '../metric-events.js'; import { ExceedsLimitError, throwExceedsLimitError, } from './exceeds-limit-error.js'; import { vi, it, expect } from 'vitest'; it('emits events event when created through the external function', () => { const emitEvent = vi.fn(); const resource = 'some-resource'; const limit = 10; expect(() => throwExceedsLimitError({ emit: emitEvent, }, { resource, limit, })).toThrow(ExceedsLimitError); expect(emitEvent).toHaveBeenCalledWith(EXCEEDS_LIMIT, { resource, limit, }); }); it('emits uses the resourceNameOverride for the event when provided, but uses the resource for the error', () => { const emitEvent = vi.fn(); const resource = 'not this'; const resourceNameOverride = 'but this!'; const limit = 10; expect(() => throwExceedsLimitError({ emit: emitEvent, }, { resource, resourceNameOverride, limit, })).toThrowError(expect.errorWithMessage(new ExceedsLimitError(resource, limit))); expect(emitEvent).toHaveBeenCalledWith(EXCEEDS_LIMIT, { resource: resourceNameOverride, limit, }); }); //# sourceMappingURL=exceeds-limit-error.test.js.map