##// END OF EJS Templates
added TraceSource tests
cin -
r11:b9900835d201 propose cancellat...
parent child
Show More
@@ -0,0 +1,29
1 define(["tape"], function(tape) {
2 "use strict";
3 var sourceId = '73a633f3-eab8-49b0-8601-07cae710f234';
4 var sourceId2 = '3ba9c7cd-ed77-437b-9a2f-1cbeb1226b5b';
5 tape('Load TraceSource for the module', function(t) {
6 require(["core/log/trace!" + sourceId, "core/log/TraceSource"], function(trace, TraceSource) {
7 t.equal(trace && trace.id, sourceId, "trace should be taken from the loader plugin parameter");
8
9 var count = 0;
10
11 var h = TraceSource.on(function(x) {
12 if(x.id == sourceId || x.id == sourceId2)
13 count++;
14 });
15
16 t.equal(count, 1, "should see created channel immediatelly");
17 t.equal(trace, TraceSource.get(sourceId), "should get same TraceSource from registry");
18 t.equal(count, 1);
19
20 TraceSource.get(sourceId2);
21
22 t.equal(count, 2);
23
24 h.destroy();
25
26 t.end();
27 });
28 });
29 }); No newline at end of file
@@ -0,0 +1,14
1 import * as TraceSource from '@implab/core/log/TraceSource'
2 import * as tape from 'tape';
3
4 const sourceId = 'test/TraceSourceTests';
5
6 tape('', t => {
7 let trace = TraceSource.get(sourceId);
8
9 let h = trace.on((sender,level,msg) => {
10
11 });
12
13 h.destroy();
14 }); No newline at end of file
@@ -3,10 +3,12 import { IActivatable } from './IActivat
3 3 import { AsyncComponent } from './AsyncComponent';
4 4 import { ICancellation } from '../ICancellation';
5 5 import { EmptyCancellation } from '../EmptyCancellation';
6 import * as log from '@implab/core/log/trace!';
6 import * as TraceSource from '../log/TraceSource';
7 7
8 8 type Constructor<T = {}> = new (...args: any[]) => T;
9 9
10 const log = TraceSource.get('@implab/core/components/ActivatableMixin');
11
10 12 function ActivatableMixin<TBase extends Constructor<AsyncComponent>>(Base: TBase) {
11 13 return class extends Base implements IActivatable {
12 14 _controller: IActivationController;
@@ -152,7 +152,7 class TraceSource {
152 152 }
153 153
154 154 static on(handler: TraceSourceHandler) {
155 Registry.instance.on(handler);
155 return Registry.instance.on(handler);
156 156 }
157 157
158 158 static get(id: any) {
@@ -1,1 +1,1
1 define(["./dummy", "./example", "./ActivatableTests"]); No newline at end of file
1 define(["./ActivatableTests", "./trace-test"]); No newline at end of file
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now