UNPKG

aono-file-handler

Version:

Aono handler that write to a log file with support for custom formatters and log rotation.

47 lines 1.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Builder_1 = require("./Builder"); const LogstashFormatter_1 = require("./LogstashFormatter"); describe('Builder', () => { let testedBuilder; let testedHandler; beforeEach(() => { testedBuilder = new Builder_1.default(); }); describe('when built with default parameters', () => { beforeEach(() => { testedHandler = testedBuilder.build(); }); it('handler contains default prefix', () => { testedHandler.prefix.should.equal('./logs/configure-me.log'); }); it('handler contains default rotation threshold', () => { testedHandler.rotationBytesThreshold.should.equal(104857600); }); it('handler contains default formatter', () => { testedHandler.formatter.should.be.instanceOf(LogstashFormatter_1.default); }); }); describe('when build with custom filePrefix', () => { const prefix = `./tmp/${new Date().getTime()}/test-`; const rotationThreshold = 123444; const formatter = { format: (entry) => 'test' }; beforeEach(() => { testedHandler = testedBuilder .prefix(prefix) .rotationBytesThreshold(rotationThreshold) .formatter(formatter) .build(); }); it('contains properly set prefix', () => { testedHandler.prefix.should.equal(prefix); }); it('contains properly set rotation threshold', () => { testedHandler.rotationBytesThreshold.should.equal(rotationThreshold); }); it('contains properly set formatter', () => { testedHandler.formatter.should.equal(formatter); }); }); }); //# sourceMappingURL=Builder.spec.js.map