1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = function (d, b) {
|
4 | extendStatics = Object.setPrototypeOf ||
|
5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7 | return extendStatics(d, b);
|
8 | };
|
9 | return function (d, b) {
|
10 | extendStatics(d, b);
|
11 | function __() { this.constructor = d; }
|
12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13 | };
|
14 | })();
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | var chai_1 = require("chai");
|
17 | var opentracing = require("../index");
|
18 | function opentracingAPITests() {
|
19 | describe('Opentracing API', function () {
|
20 | var tracer;
|
21 | var span;
|
22 | beforeEach(function () {
|
23 | tracer = new opentracing.Tracer();
|
24 | span = tracer.startSpan('test-span');
|
25 | });
|
26 | describe('Constants', function () {
|
27 | var constStrings = [
|
28 | 'FORMAT_TEXT_MAP',
|
29 | 'FORMAT_BINARY',
|
30 | 'FORMAT_HTTP_HEADERS',
|
31 | 'REFERENCE_CHILD_OF',
|
32 | 'REFERENCE_FOLLOWS_FROM'
|
33 | ];
|
34 | var _loop_1 = function (name_1) {
|
35 | it(name_1 + ' should be a constant string', function () {
|
36 | chai_1.expect(opentracing[name_1]).to.be.a('string');
|
37 | });
|
38 | };
|
39 | for (var _i = 0, constStrings_1 = constStrings; _i < constStrings_1.length; _i++) {
|
40 | var name_1 = constStrings_1[_i];
|
41 | _loop_1(name_1);
|
42 | }
|
43 | });
|
44 | describe('Standalone functions', function () {
|
45 | var funcs = [
|
46 | 'childOf',
|
47 | 'followsFrom',
|
48 | 'initGlobalTracer',
|
49 | 'globalTracer'
|
50 | ];
|
51 | var _loop_2 = function (name_2) {
|
52 | it(name_2 + ' should be a function', function () {
|
53 | chai_1.expect(opentracing[name_2]).to.be.a('function');
|
54 | });
|
55 | };
|
56 | for (var _i = 0, funcs_1 = funcs; _i < funcs_1.length; _i++) {
|
57 | var name_2 = funcs_1[_i];
|
58 | _loop_2(name_2);
|
59 | }
|
60 | describe('global tracer', function () {
|
61 | var dummySpan = new opentracing.Span();
|
62 | afterEach(function () {
|
63 | opentracing.initGlobalTracer(new opentracing.Tracer());
|
64 | });
|
65 | it('should use the global tracer', function () {
|
66 | opentracing.initGlobalTracer(new TestTracer());
|
67 | var tracer = opentracing.globalTracer();
|
68 | var span = tracer.startSpan('test');
|
69 | chai_1.expect(span).to.equal(dummySpan);
|
70 | });
|
71 | var TestTracer = (function (_super) {
|
72 | __extends(TestTracer, _super);
|
73 | function TestTracer() {
|
74 | return _super !== null && _super.apply(this, arguments) || this;
|
75 | }
|
76 | TestTracer.prototype._startSpan = function (name, fields) {
|
77 | return dummySpan;
|
78 | };
|
79 | return TestTracer;
|
80 | }(opentracing.Tracer));
|
81 | });
|
82 | });
|
83 | describe('Tracer', function () {
|
84 | it('should be a class', function () {
|
85 | chai_1.expect(new opentracing.Tracer()).to.be.an('object');
|
86 | });
|
87 | });
|
88 | describe('Span', function () {
|
89 | it('should be a class', function () {
|
90 | chai_1.expect(span).to.be.an('object');
|
91 | });
|
92 | });
|
93 | describe('SpanContext', function () {
|
94 | it('should be a class', function () {
|
95 | var spanContext = span.context();
|
96 | chai_1.expect(spanContext).to.be.an('object');
|
97 | });
|
98 | });
|
99 | describe('Reference', function () {
|
100 | it('should be a class', function () {
|
101 | var ref = new opentracing.Reference(opentracing.REFERENCE_CHILD_OF, span.context());
|
102 | chai_1.expect(ref).to.be.an('object');
|
103 | });
|
104 | });
|
105 | describe('BinaryCarrier', function () {
|
106 | it('should set binary data as a field called "buffer"', function () {
|
107 | var buffer = new Float64Array(10);
|
108 | var ref = new opentracing.BinaryCarrier(buffer);
|
109 | chai_1.expect(ref.buffer).to.equal(buffer);
|
110 | });
|
111 | });
|
112 | });
|
113 | }
|
114 | exports.opentracingAPITests = opentracingAPITests;
|
115 | exports.default = opentracingAPITests;
|
116 |
|
\ | No newline at end of file |