UNPKG

@stryker-mutator/core

Version:

The extendable JavaScript mutation testing framework

37 lines 1.88 kB
import { deepFreeze } from '@stryker-mutator/util'; import { expect } from 'chai'; import sinon from 'sinon'; import { StripAnsiAppender, configure } from '../../../src/logging/strip-ansi-appender.cjs'; import { createLoggingEvent } from './helpers.js'; describe(StripAnsiAppender.name, () => { let sut; let findAppenderStub; let innerAppender; beforeEach(() => { findAppenderStub = sinon.stub(); innerAppender = sinon.stub(); findAppenderStub.returns(innerAppender); sut = configure({ appender: 'foo' }, null, findAppenderStub); }); it('should request configured appender when configured', () => { sinon.assert.calledOnceWithExactly(findAppenderStub, 'foo'); }); it("should pass through events that don't have ANSI escape characters", () => { const actualLogEvent = createLoggingEvent({ data: ['Lorem ipsum', 42, undefined, true] }); deepFreeze(actualLogEvent); sut(actualLogEvent); sinon.assert.calledOnceWithExactly(innerAppender, actualLogEvent); // check to see if it the same instance expect(innerAppender.getCall(0).args[0]).eq(actualLogEvent); }); it('should pass through a shallow copy with removed ANSI escape characters', () => { const logEvent = createLoggingEvent({ data: ['0 files changed (+0 -0)', 42, undefined, true] }); const expectedLogEvent = createLoggingEvent({ data: ['0 files changed (+0 -0)', 42, undefined, true], serialise: logEvent.serialise }); deepFreeze(logEvent); sut(logEvent); sinon.assert.calledOnceWithExactly(innerAppender, expectedLogEvent); // check to see that it is not the same instance expect(innerAppender.getCall(0).args[0]).not.eq(logEvent); }); }); //# sourceMappingURL=strip-ansi-appender.spec.js.map