11import { Trace } from '../src/trace/trace' ;
2+ import { Span } from '../src/trace/span' ;
23
3- var assert = require ( 'assert' ) ;
4+ let assert = require ( 'assert' ) ;
45
5- describe ( 'Trace' , function ( ) {
6- it ( 'should be a Trace instance' , function ( ) {
7- var trace = new Trace ( ) ;
8- assert . ok ( trace instanceof Trace ) ;
6+ describe ( 'Trace' , function ( ) {
7+ describe ( 'new Trace()' , function ( ) {
8+ it ( 'should be a Trace instance' , function ( ) {
9+ let trace = new Trace ( ) ;
10+ assert . ok ( trace instanceof Trace ) ;
11+ } ) ;
912 } ) ;
13+
14+ describe ( 'start()' , function ( ) {
15+ it ( 'trace was started' , function ( ) {
16+ let trace = new Trace ( ) ;
17+ trace . start ( ) ;
18+ assert . ok ( trace . started ) ;
19+ } ) ;
20+ } ) ;
21+
22+ describe ( 'startSpan()' , function ( ) {
23+ let trace = new Trace ( ) ;
24+ trace . start ( )
25+ let span = trace . startSpan ( "spanName" , "spanType" ) ;
26+ it ( 'should be a Span instance' , function ( ) {
27+ assert . ok ( span instanceof Span ) ;
28+ } ) ;
29+
30+ it ( 'span was started' , function ( ) {
31+ assert . ok ( span . started ) ;
32+ } ) ;
33+ } ) ;
34+
35+ describe ( 'end()' , function ( ) {
36+ it ( 'trace was ended' , function ( ) {
37+ let trace = new Trace ( ) ;
38+ trace . start ( )
39+ trace . end ( ) ;
40+ assert . ok ( trace . ended ) ;
41+ } ) ;
42+ } ) ;
43+
44+ describe ( 'end() before trace started' , function ( ) {
45+ it ( 'trace was not ended' , function ( ) {
46+ let trace = new Trace ( ) ;
47+ trace . end ( ) ;
48+ assert . ok ( ! trace . ended ) ;
49+ } ) ;
50+ } ) ;
51+
52+ describe ( 'startSpan() before trace started' , function ( ) {
53+ it ( 'should return null' , function ( ) {
54+ let trace = new Trace ( ) ;
55+ let span = trace . startSpan ( "spanName" , "spanType" ) ;
56+ assert . ok ( span == null ) ;
57+ } ) ;
58+ } ) ;
59+
60+ describe ( 'startSpan() after trace ended' , function ( ) {
61+ it ( 'should return null' , function ( ) {
62+ let trace = new Trace ( ) ;
63+ trace . start ( )
64+ trace . end ( ) ;
65+ let span = trace . startSpan ( "spanName" , "spanType" ) ;
66+ assert . ok ( span == null ) ;
67+ } ) ;
68+ } ) ;
69+
1070} ) ;
0 commit comments