Skip to content

Commit

Permalink
test(metrics): make sure metadata is kept
Browse files Browse the repository at this point in the history
  • Loading branch information
mentos1386 committed Mar 29, 2022
1 parent c34ae56 commit cec6d37
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/metrics/decorators/common.spec.ts
@@ -0,0 +1,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);
});
});

0 comments on commit cec6d37

Please sign in to comment.