##// END OF EJS Templates
working on Observable
working on Observable

File last commit:

r14:53e756f117f7 propose cancellat...
r14:53e756f117f7 propose cancellat...
Show More
TraceSourceTests.ts
61 lines | 1.5 KiB | video/mp2t | TypeScriptLexer
/ test / ts / TraceSourceTests.ts
cin
added TraceSource tests
r11 import * as TraceSource from '@implab/core/log/TraceSource'
import * as tape from 'tape';
cin
working on Observable
r14 import * as ConsoleWriter from '@implab/core/log/writers/ConsoleWriter';
cin
added TraceSource tests
r11
const sourceId = 'test/TraceSourceTests';
cin
refactoring, all common interfaces placed to core/interfaces.ts...
r13 tape('trace message', t => {
cin
added TraceSource tests
r11 let trace = TraceSource.get(sourceId);
cin
removed obsolete code
r12 trace.level = TraceSource.DebugLevel;
cin
added TraceSource tests
r11
cin
working on Observable
r14 let h = trace.on((ev) => {
t.equal(ev.source, trace, "sender should be the current trace source");
t.equal(ev.level, TraceSource.DebugLevel, "level should be debug level");
t.equal(ev.arg, "Hello, World!", "The message should be a formatted message");
cin
removed obsolete code
r12
t.end();
cin
added TraceSource tests
r11 });
cin
removed obsolete code
r12 trace.debug("Hello, {0}!", "World");
cin
added TraceSource tests
r11 h.destroy();
cin
refactoring, all common interfaces placed to core/interfaces.ts...
r13 });
tape('trace event', t => {
let trace = TraceSource.get(sourceId);
trace.level = TraceSource.DebugLevel;
let event = {
name: "custom event"
};
cin
working on Observable
r14 let h = trace.on((ev) => {
t.equal(ev.source, trace, "sender should be the current trace source");
t.equal(ev.level, TraceSource.DebugLevel, "level should be debug level");
t.equal(ev.arg, event, "The message should be the specified object");
cin
refactoring, all common interfaces placed to core/interfaces.ts...
r13
t.end();
});
trace.traceEvent(TraceSource.DebugLevel, event);
h.destroy();
cin
working on Observable
r14 });
tape('console writer', async t => {
let writer = new ConsoleWriter();
let trace = TraceSource.get(sourceId);
trace.level = TraceSource.DebugLevel;
let p = writer.write(trace);
trace.log("Hello, {0}!", 'World');
trace.warn("Look at me!");
trace.error("DIE!");
console.log("DONE");
t.end();
cin
added TraceSource tests
r11 });