Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit a221c63

Browse files
added test-tracemanager
1 parent 3a1fd0d commit a221c63

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { TraceManager } from '../src/trace/tracemanager';
2+
import { Trace } from '../src/trace/trace';
3+
import { Span } from '../src/trace/span';
4+
5+
let assert = require('assert');
6+
7+
describe('TraceManager', function () {
8+
describe('new TraceManager()', function () {
9+
it('should be a TraceManager instance', function () {
10+
let traceManager = new TraceManager();
11+
assert.ok(traceManager instanceof TraceManager);
12+
});
13+
});
14+
15+
describe('start()', function () {
16+
let traceManager = new TraceManager();
17+
let traceManagerStarted = traceManager.start();
18+
19+
it('should return a TraceManager instance', function () {
20+
assert.ok(traceManagerStarted instanceof TraceManager);
21+
});
22+
23+
it('should set true on active property', function () {
24+
assert.ok(traceManagerStarted.active);
25+
});
26+
});
27+
28+
describe('startTrace()', function () {
29+
let traceManager;
30+
let trace;
31+
32+
before(() => {
33+
traceManager = new TraceManager();
34+
trace = traceManager.startTrace();
35+
})
36+
37+
it('should return a Trace instance', function () {
38+
assert.ok(trace instanceof Trace);
39+
});
40+
41+
it('the new trace was set as current trace', function () {
42+
assert.equal(traceManager.currentTrace.id, trace.id);
43+
});
44+
45+
it('the new trace was started', function () {
46+
assert.ok(trace.started);
47+
});
48+
});
49+
50+
describe('endTrace()', function () {
51+
it('the current trace was ended', function () {
52+
let traceManager = new TraceManager();
53+
let trace = traceManager.startTrace();
54+
traceManager.endTrace();
55+
assert.ok(trace.ended);
56+
});
57+
});
58+
59+
describe('clearCurrentTrace()', function () {
60+
it('the current trace is null', function () {
61+
let traceManager = new TraceManager();
62+
let trace = traceManager.startTrace();
63+
traceManager.clearCurrentTrace();
64+
assert.ok(traceManager.currentTrace == null);
65+
});
66+
});
67+
68+
describe('startSpan()', function () {
69+
let traceManager = new TraceManager();
70+
let trace = traceManager.startTrace();
71+
let span = traceManager.startSpan("spanName", "spanType");
72+
it('should return a Span instance', function () {
73+
assert.ok(span instanceof Span);
74+
});
75+
76+
it('span was started', function () {
77+
assert.ok(span.started);
78+
});
79+
});
80+
81+
});

0 commit comments

Comments
 (0)