all files / spec/ firehoseLoggerAdapterSpec.js

100% Statements 21/21
100% Branches 0/0
100% Functions 0/0
100% Lines 17/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                              
const FirehoseLoggerAdapter = require('../lib/index.js').FirehoseLoggerAdapter;
const config = require('config');
 
// If you want to actually send a test log, then set NODE_ENV to something
// other than 'test'.  See spec/helpers
// process.env.NODE_ENV = 'foo';
describe('FirehoseLoggerAdapter configuration tests', () => {
  it('missing arguments throws', () => {
    expect(() => new FirehoseLoggerAdapter()).toThrow();
  });
 
  it('can configure with options', () => {
    expect(() => new FirehoseLoggerAdapter({ streamName: 'test-stream' })).not.toThrow();
  });
 
  it('can configure with string arg', () => {
    expect(() => new FirehoseLoggerAdapter('test-stream')).not.toThrow();
  });
 
  it('can configure with env var', () => {
    process.env.FIREHOSE_LOGGER_STREAM_NAME = 'test-stream';
    expect(() => new FirehoseLoggerAdapter()).not.toThrow();
    delete process.env.FIREHOSE_LOGGER_STREAM_NAME;
  });
 
  it('should be able to use immutable config', () => {
    const options = config.get('loggerOptions');
    const logger = new FirehoseLoggerAdapter(options);
    expect(logger).not.toBe(null);
  });
});