Skip to content

Commit 117ba0b

Browse files
committed
Move CustomDataLoader class inside the test case.
1 parent 60d8499 commit 117ba0b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

plugins/node/instrumentation-dataloader/test/dataloader.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,10 @@ import * as assert from 'assert';
3333
import * as Dataloader from 'dataloader';
3434
import * as crypto from 'crypto';
3535

36-
const getMd5HashFromIdx = (idx: number) =>
37-
crypto.createHash('md5').update(String(idx)).digest('hex');
38-
3936
describe('DataloaderInstrumentation', () => {
4037
let dataloader: Dataloader<string, number>;
4138
let contextManager: AsyncHooksContextManager;
4239

43-
class CustomDataLoader extends Dataloader<string, string> {
44-
constructor() {
45-
super(async keys => keys.map((_, idx) => getMd5HashFromIdx(idx)));
46-
}
47-
48-
public async customLoad() {
49-
return this.load('test');
50-
}
51-
}
52-
5340
const memoryExporter = new InMemorySpanExporter();
5441
const provider = new NodeTracerProvider();
5542
const tracer = provider.getTracer('default');
@@ -350,6 +337,19 @@ describe('DataloaderInstrumentation', () => {
350337
});
351338

352339
it('should not prune custom methods', async () => {
340+
const getMd5HashFromIdx = (idx: number) =>
341+
crypto.createHash('md5').update(String(idx)).digest('hex');
342+
343+
class CustomDataLoader extends Dataloader<string, string> {
344+
constructor() {
345+
super(async keys => keys.map((_, idx) => getMd5HashFromIdx(idx)));
346+
}
347+
348+
public async customLoad() {
349+
return this.load('test');
350+
}
351+
}
352+
353353
const customDataloader = new CustomDataLoader();
354354
await customDataloader.customLoad();
355355

0 commit comments

Comments
 (0)