tests
This commit is contained in:
parent
3a7254708e
commit
b63e58784c
41 changed files with 5762 additions and 4477 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { describe, expect, it, beforeEach, mock } from 'bun:test';
|
||||
import { beforeEach, describe, expect, it, mock } from 'bun:test';
|
||||
import { OperationContext } from '../src/operation-context';
|
||||
import type { OperationContextOptions } from '../src/operation-context';
|
||||
|
||||
|
|
@ -21,9 +21,7 @@ describe('OperationContext', () => {
|
|||
// Reset mocks
|
||||
Object.keys(mockLogger).forEach(key => {
|
||||
if (typeof mockLogger[key as keyof typeof mockLogger] === 'function') {
|
||||
(mockLogger as any)[key] = mock(() =>
|
||||
key === 'child' ? mockLogger : undefined
|
||||
);
|
||||
(mockLogger as any)[key] = mock(() => (key === 'child' ? mockLogger : undefined));
|
||||
}
|
||||
});
|
||||
mockContainer.resolve = mock((name: string) => ({ name }));
|
||||
|
|
@ -38,7 +36,7 @@ describe('OperationContext', () => {
|
|||
};
|
||||
|
||||
const context = new OperationContext(options);
|
||||
|
||||
|
||||
expect(context).toBeDefined();
|
||||
expect(context.traceId).toBeDefined();
|
||||
expect(context.metadata).toEqual({});
|
||||
|
|
@ -56,7 +54,7 @@ describe('OperationContext', () => {
|
|||
};
|
||||
|
||||
const context = new OperationContext(options);
|
||||
|
||||
|
||||
expect(context.traceId).toBe('custom-trace-id');
|
||||
expect(context.metadata).toEqual({ key: 'value' });
|
||||
expect(context.logger).toBe(mockLogger);
|
||||
|
|
@ -114,7 +112,9 @@ describe('OperationContext', () => {
|
|||
operationName: 'test-op',
|
||||
});
|
||||
|
||||
await expect(context.resolveAsync('service')).rejects.toThrow('No service container available');
|
||||
await expect(context.resolveAsync('service')).rejects.toThrow(
|
||||
'No service container available'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -270,4 +270,4 @@ describe('OperationContext', () => {
|
|||
expect(context1.traceId).toMatch(/^\d+-[a-z0-9]+$/);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue