( func?: (this: Self, ...args: Args) => Return, )
| 508 | func: (this: Self, ...args: Args) => Return, |
| 509 | ): (this: Self, ...args: Args) => Return; |
| 510 | export function mockSession< |
| 511 | Self, |
| 512 | Args extends unknown[], |
| 513 | Return, |
| 514 | >( |
| 515 | func?: (this: Self, ...args: Args) => Return, |
| 516 | ): number | ((this: Self, ...args: Args) => Return) { |
| 517 | if (func) { |
| 518 | return function (this: Self, ...args: Args): Return { |
| 519 | const id = sessions.length; |
| 520 | sessions.push(new Set()); |
| 521 | try { |
| 522 | return func.apply(this, args); |
| 523 | } finally { |
| 524 | restore(id); |
| 525 | } |
| 526 | }; |
| 527 | } else { |
| 528 | sessions.push(new Set()); |
| 529 | return sessions.length - 1; |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | /** |
| 534 | * Creates an async session that tracks all mocks created before the promise resolves. |
no test coverage detected