|
| 1 | +import { Span } from '../src/trace/span'; |
| 2 | +import { Trace } from '../src/trace/trace'; |
| 3 | + |
| 4 | +var assert = require('assert'); |
| 5 | + |
| 6 | +describe('Span creation', function () { |
| 7 | + |
| 8 | + let trace; |
| 9 | + let span; |
| 10 | + |
| 11 | + before(function () { |
| 12 | + trace = new Trace(); |
| 13 | + span = trace.startSpan('spanName', 'typeSpan'); |
| 14 | + }); |
| 15 | + |
| 16 | + it('should create an span on the trace', function () { |
| 17 | + assert.ok(trace instanceof Trace); |
| 18 | + span = trace.startSpan('spanName', 'typeSpan'); |
| 19 | + assert.ok(span instanceof Span); |
| 20 | + assert.ok(span.id); |
| 21 | + }); |
| 22 | + |
| 23 | + it('should start a span', function () { |
| 24 | + span.start(); |
| 25 | + assert.ok(span.started); |
| 26 | + }); |
| 27 | + |
| 28 | + it('should end a span', function () { |
| 29 | + span.end(); |
| 30 | + assert.ok(span.ended); |
| 31 | + }); |
| 32 | +}); |
| 33 | + |
| 34 | +describe('Span checking creation', function () { |
| 35 | + |
| 36 | + let trace; |
| 37 | + let span; |
| 38 | + |
| 39 | + before(function () { |
| 40 | + trace = new Trace(); |
| 41 | + span = trace.startSpan('spanName', 'typeSpan'); |
| 42 | + }); |
| 43 | + |
| 44 | + it('should not start span after it ended', function () { |
| 45 | + span.end(); |
| 46 | + assert.equal(span.ended, true); |
| 47 | + }); |
| 48 | +}); |
| 49 | + |
| 50 | +describe('Span data', function () { |
| 51 | + |
| 52 | + let trace; |
| 53 | + |
| 54 | + before(function () { |
| 55 | + trace = new Trace(); |
| 56 | + }); |
| 57 | + |
| 58 | + it('generates unique numeric span ID strings', function () { |
| 59 | + var numberOfSpansToCheck = 5; |
| 60 | + for (var i = 0; i < numberOfSpansToCheck; i++) { |
| 61 | + var span = trace.startSpan('spanName' + i, 'typeSpan' + i); |
| 62 | + var spanId = span.id; |
| 63 | + assert.ok(typeof spanId === 'string'); |
| 64 | + assert.ok(spanId.match(/\d+/)); |
| 65 | + assert.ok(Number(spanId) > 0); |
| 66 | + assert.strictEqual(Number(spanId).toString(), spanId); |
| 67 | + } |
| 68 | + }); |
| 69 | + |
| 70 | + // TODO |
| 71 | + it('truncates namespace', function(){ |
| 72 | + this.skip(); |
| 73 | + }); |
| 74 | +}); |
| 75 | + |
0 commit comments