Scribe.js/tests/console.test.js

65 lines
2.1 KiB
JavaScript
Raw Normal View History

import * as Scribe from '../'
2016-01-22 08:22:11 -06:00
import expect from 'expect.js'
import TraceError from 'trace-error';
2016-01-22 08:22:11 -06:00
describe('Basic Scribe', ()=> {
const console = Scribe.create();
2016-01-22 08:22:11 -06:00
console.persistent('tags', ['mocha', 'scribe']);
it('should print objects to terminal', async () => {
await console.tag('object').log('Inspect object', {test: true});
await console.tag('object').log('Inspect object', console);
await console.log();
2016-01-22 08:22:11 -06:00
});
it('should print functions to terminal', async () => {
await console.tag('function').log('Inspect function', Function);
2016-01-22 08:22:11 -06:00
});
it('should print metrics to terminal', async () => {
await console.tag('metric').metric('appTime', 500, 'dbTime', 750).log('Inspect metric');
await console.tag('metric').metric('appTime', 500, 'dbTime', 750).log()
2016-01-22 08:22:11 -06:00
});
it('should print errors to terminal', async () => {
await console.tag('error').error(new Error('Scribe error test 1'));
await console.tag('error').error(new Error('Scribe error test 2'));
await console.tag('error').error(new TraceError('Scribe error test 2', new Error("Sub error")));
await console.tag('error').error(JSON.stringify(new TraceError('test error', new Error("Sub error")),
["message", "arguments", "type", "name", "stack"]));
2016-01-22 08:22:11 -06:00
});
it('should print dates to terminal', async () => {
await console.tag('date').log(new Date());
2016-01-22 08:22:11 -06:00
});
it('should print booleans to terminal', async () => {
await console.tag('boolean').log(true);
2016-01-22 08:22:11 -06:00
});
it('should print maps to terminal', async () => {
2016-01-22 08:22:11 -06:00
let map0 = new Map(), map1 = new WeakMap();
map0.set('scribe', 'test');
map1.set({}, 'test');
await console.tag('map').log(map0);
await console.tag('map').log(map1);
2016-01-22 08:22:11 -06:00
});
it('should print sets to terminal', async () => {
2016-01-22 08:22:11 -06:00
let set0 = new Set(), set1 = new WeakSet();
set0.add('scribe');
set1.add({});
await console.tag('set').log(set0);
await console.tag('set').log(set1);
2016-01-22 08:22:11 -06:00
});
it('should print promises to terminal', async () => {
2016-01-22 08:22:11 -06:00
const promise = new Promise(()=> 0);
await console.tag('promise').log(promise, promise instanceof Promise);
2016-01-22 08:22:11 -06:00
});
});