1414 * limitations under the License.
1515 */
1616
17- import { ConsoleExporter , Exporter , Tracer , TracerImpl , Tracing } from '@opencensus/opencensus-core' ;
18- import * as assert from 'assert' ;
17+ import { ConsoleExporter } from '@opencensus/opencensus-core' ;
18+ import { Exporter } from '@opencensus/opencensus-core' ;
19+ import { Tracer } from '@opencensus/opencensus-core' ;
20+ import { TracerImpl } from '@opencensus/opencensus-core' ;
21+ import { Tracing } from '@opencensus/opencensus-core' ;
22+ import { Logger } from '@opencensus/opencensus-core' ;
23+ import { Config , TracingConfig } from '@opencensus/opencensus-core' ;
24+ import { NoopExporter } from '@opencensus/opencensus-core' ;
25+
26+ import * as logger from '@opencensus/opencensus-core' ;
1927
2028import { TracingImpl } from '../src/trace/tracing' ;
29+ import * as assert from 'assert' ;
2130
31+
32+ const NOOP_EXPORTER = new NoopExporter ( ) ;
2233describe ( 'Tracing' , ( ) => {
2334 /** Should create a Tracing instance */
2435 describe ( 'new Tracing()' , ( ) => {
@@ -39,16 +50,30 @@ describe('Tracing', () => {
3950 /** Should return a started tracing instance */
4051 describe ( 'start()' , ( ) => {
4152 let tracingStarted : Tracing ;
42- before ( ( ) => {
43- const tracing = new TracingImpl ( ) ;
44- tracingStarted = tracing . start ( ) ;
45- } ) ;
53+ const tracing = new TracingImpl ( ) ;
54+ // tslint:disable:no-any
55+ function instanceOfLogger ( object : any ) : object is Logger {
56+ return 'debug' in object ;
57+ }
58+
4659 it ( 'should return a tracing instance' , ( ) => {
60+ tracingStarted = tracing . start ( ) ;
4761 assert . ok ( tracingStarted instanceof TracingImpl ) ;
4862 } ) ;
4963
5064 it ( 'the tracing was started' , ( ) => {
65+ tracingStarted = tracing . start ( ) ;
5166 assert . ok ( tracingStarted . tracer . active ) ;
67+ } ) ;
68+ it ( 'should tracing.tracer instance with logger' , ( ) => {
69+
70+ tracingStarted = tracing . start ( { logger :logger . logger ( 'debug' ) } ) ;
71+ assert . ok ( instanceOfLogger ( tracingStarted . tracer . logger ) ) ;
72+ } ) ;
73+ it ( 'should tracing.tracer instance with exporter' , ( ) => {
74+
75+ tracingStarted = tracing . start ( { exporter : NOOP_EXPORTER } ) ;
76+ assert . equal ( tracingStarted . exporter , NOOP_EXPORTER ) ;
5277 } ) ;
5378 } ) ;
5479
0 commit comments