Skip to content

Commit 45273a3

Browse files
committed
fix coverage
1 parent e2f638c commit 45273a3

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

src/__testUtils__/__tests__/expectEvents-test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,34 @@ describe('expectEvents', () => {
9797
);
9898
});
9999

100+
it('collects events with non-object contexts', async () => {
101+
const channel = createFakeTracingChannel();
102+
103+
await expectEvents(
104+
channel,
105+
() => {
106+
channel.start.publish(null);
107+
channel.end.publish(undefined);
108+
channel.error.publish('error');
109+
return 'done';
110+
},
111+
(_result) => [
112+
{
113+
channel: 'start',
114+
context: null,
115+
},
116+
{
117+
channel: 'end',
118+
context: undefined,
119+
},
120+
{
121+
channel: 'error',
122+
context: 'error',
123+
},
124+
],
125+
);
126+
});
127+
100128
it('unsubscribes when the callback rejects', async () => {
101129
let activeHandler: object | undefined;
102130
const error = new Error('boom');

src/__testUtils__/__tests__/expectNoTracingActivity-test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,22 @@ describe('expectNoTracingActivity', () => {
7575

7676
expect(channel.start.publish).to.equal(originalPublish);
7777
});
78+
79+
it('fails when traceSync is called', async () => {
80+
const channel = createFakeTracingChannel();
81+
await expectPromise(
82+
expectNoTracingActivity(channel, () => {
83+
channel.traceSync(() => 'ok', {}, undefined);
84+
}),
85+
).toRejectWith("expected [ 'traceSync' ] to deeply equal []");
86+
});
87+
88+
it('fails when runStores is called', async () => {
89+
const channel = createFakeTracingChannel();
90+
await expectPromise(
91+
expectNoTracingActivity(channel, () => {
92+
channel.start.runStores({}, () => 'ok');
93+
}),
94+
).toRejectWith("expected [ 'start.runStores' ] to deeply equal []");
95+
});
7896
});

src/__testUtils__/expectNoTracingActivity.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export async function expectNoTracingActivity<T>(
2424
channel,
2525
'traceSync',
2626
(original) =>
27+
// c8 ignore next 5
2728
function interceptedTraceSync(
2829
this: unknown,
2930
...args: Array<unknown>
@@ -55,6 +56,7 @@ export async function expectNoTracingActivity<T>(
5556
subChannel,
5657
'runStores',
5758
(original) =>
59+
// c8 ignore next 6
5860
function interceptedRunStores(
5961
this: unknown,
6062
...args: Array<unknown>

0 commit comments

Comments
 (0)