UNPKG

cloudworker-proxy

Version:
37 lines (29 loc) 664 B
const { expect } = require('chai'); const HttpLogger = require('../../src/loggers/http'); describe('httpLogger', () => { let realFetch, fetchCalls; const mockFetch = async (url, options) => { fetchCalls.push({ url, options, }); }; beforeEach(() => { realFetch = global.fetch; fetchCalls = []; global.fetch = mockFetch; }); afterEach(() => { global.fetch = realFetch; }); it('should send a message to a http endpoint', async () => { const logger = new HttpLogger({ ctx: {}, maxSize: 0, }); logger.log({ foo: 'bar', }); expect(fetchCalls.length).to.equal(1); }); });