|
1 | 1 | /** |
2 | | -* Copyright 2018 Google Inc. All Rights Reserved. |
3 | | -* |
4 | | -* Licensed under the Apache License, Version 2.0 (the 'License'); |
5 | | -* you may not use this file except in compliance with the License. |
6 | | -* You may obtain a copy of the License at |
7 | | -* |
8 | | -* http://www.apache.org/licenses/LICENSE-2.0 |
9 | | -* |
10 | | -* Unless required by applicable law or agreed to in writing, software |
11 | | -* distributed under the License is distributed on an 'AS IS' BASIS, |
12 | | -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | -* See the License for the specific language governing permissions and |
14 | | -* limitations under the License. |
15 | | -*/ |
| 2 | + * Copyright 2018 Google Inc. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the 'License'); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an 'AS IS' BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
16 | 16 |
|
17 | | -import { RootSpan } from '../src/trace/model/rootspan'; |
18 | | -import { Span } from '../src/trace/model/span'; |
19 | | -import { Tracer } from '../src/trace/model/tracer'; |
20 | | -import { SpanBaseModel } from '../src/trace/types/tracetypes'; |
| 17 | +import * as assert from 'assert'; |
| 18 | + |
| 19 | +import {RootSpan} from '../src/trace/model/rootspan'; |
| 20 | +import {Span} from '../src/trace/model/span'; |
| 21 | +import {Tracer} from '../src/trace/model/tracer'; |
| 22 | +import {SpanBaseModel} from '../src/trace/types/tracetypes'; |
21 | 23 |
|
22 | | -let assert = require('assert'); |
23 | 24 | let tracer = new Tracer(); |
24 | 25 |
|
25 | | -describe('RootSpan', function () { |
26 | | - describe('new RootSpan()', function () { |
27 | | - it('should create a RootSpan instance', function () { |
28 | | - let root = new RootSpan(tracer); |
29 | | - assert.ok(root instanceof SpanBaseModel); |
30 | | - }); |
| 26 | +describe('RootSpan', function() { |
| 27 | + /** |
| 28 | + * Should create a RootSpan instance |
| 29 | + */ |
| 30 | + describe('new RootSpan()', function() { |
| 31 | + it('should create a RootSpan instance', function() { |
| 32 | + let root = new RootSpan(tracer); |
| 33 | + assert.ok(root instanceof SpanBaseModel); |
31 | 34 | }); |
| 35 | + }); |
32 | 36 |
|
33 | | - describe('start()', function () { |
34 | | - |
35 | | - it('should start a RootSpan instance', function () { |
36 | | - let root = new RootSpan(tracer); |
37 | | - root.start(); |
38 | | - assert.ok(root.started); |
39 | | - }); |
40 | | - |
| 37 | + /** |
| 38 | + * Should create and start a RootSpan instance |
| 39 | + */ |
| 40 | + describe('start()', function() { |
| 41 | + it('should start a RootSpan instance', function() { |
| 42 | + let root = new RootSpan(tracer); |
| 43 | + root.start(); |
| 44 | + assert.ok(root.started); |
41 | 45 | }); |
| 46 | + }); |
42 | 47 |
|
43 | | - describe('startSpan()', function () { |
| 48 | + /** |
| 49 | + * Should check type and a span was started |
| 50 | + */ |
| 51 | + describe('startSpan()', function() { |
| 52 | + let root, span; |
44 | 53 |
|
45 | | - let root, span; |
46 | | - |
47 | | - before(function () { |
48 | | - root = new RootSpan(tracer); |
49 | | - root.start(); |
50 | | - span = root.startSpan('spanName', 'spanType'); |
51 | | - }); |
| 54 | + before(function() { |
| 55 | + root = new RootSpan(tracer); |
| 56 | + root.start(); |
| 57 | + span = root.startSpan('spanName', 'spanType'); |
| 58 | + }); |
52 | 59 |
|
53 | | - it('should check span instance type', function () { |
54 | | - assert.ok(span instanceof Span); |
55 | | - }); |
| 60 | + it('should check span instance type', function() { |
| 61 | + assert.ok(span instanceof Span); |
| 62 | + }); |
56 | 63 |
|
57 | | - it('should check if a new span was started', function () { |
58 | | - assert.ok(span.started); |
59 | | - }); |
| 64 | + it('should check if a new span was started', function() { |
| 65 | + assert.ok(span.started); |
60 | 66 | }); |
| 67 | + }); |
61 | 68 |
|
62 | | - describe('end()', function () { |
63 | | - it('should end the trace', function () { |
64 | | - let root = new RootSpan(tracer); |
65 | | - root.start(); |
66 | | - root.end(); |
67 | | - assert.ok(root.ended); |
68 | | - }); |
| 69 | + /** |
| 70 | + * Should start and end a rootspan properly |
| 71 | + */ |
| 72 | + describe('end()', function() { |
| 73 | + it('should end the trace', function() { |
| 74 | + let root = new RootSpan(tracer); |
| 75 | + root.start(); |
| 76 | + root.end(); |
| 77 | + assert.ok(root.ended); |
69 | 78 | }); |
| 79 | + }); |
70 | 80 |
|
71 | | - describe('end() before trace started', function () { |
72 | | - it('should not end trace', function () { |
73 | | - let root = new RootSpan(tracer); |
74 | | - root.end(); |
75 | | - assert.ok(!root.ended); |
76 | | - }); |
| 81 | + /** |
| 82 | + * Should not end a rootspan which was not started |
| 83 | + */ |
| 84 | + describe('end() before trace started', function() { |
| 85 | + it('should not end trace', function() { |
| 86 | + let root = new RootSpan(tracer); |
| 87 | + root.end(); |
| 88 | + assert.ok(!root.ended); |
77 | 89 | }); |
| 90 | + }); |
78 | 91 |
|
79 | | - describe('startSpan() before trace started', function () { |
80 | | - it('should not create span', function () { |
81 | | - let root = new RootSpan(tracer); |
82 | | - let span = root.startSpan('spanName', 'spanType'); |
83 | | - assert.ok(span == null); |
84 | | - }); |
| 92 | + /** |
| 93 | + * Should not start a span from a not started rootspan |
| 94 | + */ |
| 95 | + describe('startSpan() before trace started', function() { |
| 96 | + it('should not create span', function() { |
| 97 | + let root = new RootSpan(tracer); |
| 98 | + let span = root.startSpan('spanName', 'spanType'); |
| 99 | + assert.ok(span == null); |
85 | 100 | }); |
| 101 | + }); |
86 | 102 |
|
87 | | - describe('startSpan() after trace ended', function () { |
88 | | - it('should not create span', function () { |
89 | | - let root = new RootSpan(tracer); |
90 | | - root.start(); |
91 | | - root.end(); |
92 | | - let span = root.startSpan('spanName', 'spanType'); |
93 | | - assert.ok(span == null); |
94 | | - }); |
| 103 | + /** |
| 104 | + * Should not create a span from a ended rootspan |
| 105 | + */ |
| 106 | + describe('startSpan() after trace ended', function() { |
| 107 | + it('should not create span', function() { |
| 108 | + let root = new RootSpan(tracer); |
| 109 | + root.start(); |
| 110 | + root.end(); |
| 111 | + let span = root.startSpan('spanName', 'spanType'); |
| 112 | + assert.ok(span == null); |
95 | 113 | }); |
| 114 | + }); |
96 | 115 | }); |
0 commit comments