@@ -4,22 +4,24 @@ import { Span } from '../src/trace/span';
44let assert = require ( 'assert' ) ;
55
66describe ( 'Trace' , function ( ) {
7- let trace = new Trace ( ) ;
8-
9- describe ( 'new Trace()' , function ( ) {
10- it ( 'should be a Trace instance' , function ( ) {
7+ describe ( 'new Trace()' , function ( ) {
8+ it ( 'should be a Trace instance' , function ( ) {
9+ let trace = new Trace ( ) ;
1110 assert . ok ( trace instanceof Trace ) ;
1211 } ) ;
1312 } ) ;
1413
1514 describe ( 'start()' , function ( ) {
1615 it ( 'trace was started' , function ( ) {
17- trace . start ( )
16+ let trace = new Trace ( ) ;
17+ trace . start ( ) ;
1818 assert . ok ( trace . started ) ;
1919 } ) ;
2020 } ) ;
2121
2222 describe ( 'startSpan()' , function ( ) {
23+ let trace = new Trace ( ) ;
24+ trace . start ( )
2325 let span = trace . startSpan ( "spanName" , "spanType" ) ;
2426 it ( 'should be a Span instance' , function ( ) {
2527 assert . ok ( span instanceof Span ) ;
@@ -32,14 +34,36 @@ describe('Trace', function () {
3234
3335 describe ( 'end()' , function ( ) {
3436 it ( 'trace was ended' , function ( ) {
37+ let trace = new Trace ( ) ;
38+ trace . start ( )
3539 trace . end ( ) ;
3640 assert . ok ( trace . ended ) ;
3741 } ) ;
3842 } ) ;
3943
40- describe ( 'startSpan() after ended trace' , function ( ) {
41- it ( 'should throws an exception' , function ( ) {
42- assert . throws ( ( ) => trace . startSpan ( "spanName" , "spanType" ) ) ;
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 ) ;
4367 } ) ;
4468 } ) ;
4569
0 commit comments