/
common.spec.ts
37 lines (29 loc) 路 923 Bytes
/
common.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'reflect-metadata';
import { SetMetadata } from '@nestjs/common';
import { OtelInstanceCounter, OtelMethodCounter } from './common';
const TestDecoratorThatSetsMetadata = () => SetMetadata('some-metadata', true);
@OtelInstanceCounter()
@TestDecoratorThatSetsMetadata()
class TestClass {
@TestDecoratorThatSetsMetadata()
@OtelMethodCounter()
method() {}
}
describe('OtelInstanceCounter', () => {
let instance: TestClass;
beforeEach(() => {
instance = new TestClass();
});
it('should maintain reflect metadata', async () => {
expect(Reflect.getMetadata('some-metadata', instance.constructor)).toEqual(true);
});
});
describe('OtelMethodCounter', () => {
let instance: TestClass;
beforeEach(() => {
instance = new TestClass();
});
it('should maintain reflect metadata', async () => {
expect(Reflect.getMetadata('some-metadata', instance.method)).toEqual(true);
});
});