Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(metrics): make sure metadata is kept
- Loading branch information
1 parent
c34ae56
commit cec6d37
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); |