File tree 2 files changed +37
-6
lines changed
2 files changed +37
-6
lines changed Original file line number Diff line number Diff line change
1
+ export default typeof AbortController === "undefined" ? mockit : it ;
2
+
3
+ function mockit ( description , run ) {
4
+ return it ( description , withMock ( run ) ) ;
5
+ }
6
+
7
+ mockit . skip = ( description , run ) => {
8
+ return it . skip ( description , withMock ( run ) ) ;
9
+ } ;
10
+
11
+ mockit . only = ( description , run ) => {
12
+ return it . only ( description , withMock ( run ) ) ;
13
+ } ;
14
+
15
+ class MockAbortController {
16
+ abort ( ) {
17
+ // mock noop for node 14
18
+ }
19
+ }
20
+
21
+ function withMock ( run ) {
22
+ return async ( ) => {
23
+ global . AbortController = MockAbortController ;
24
+ try {
25
+ return await run ( ) ;
26
+ } finally {
27
+ delete global . AbortController ;
28
+ }
29
+ } ;
30
+ }
31
+
32
+ export function invalidator ( ) {
33
+ let invalidate ;
34
+ const invalidation = new Promise ( ( resolve ) => ( invalidate = resolve ) ) ;
35
+ return [ invalidation , invalidate ] ;
36
+ }
Original file line number Diff line number Diff line change 1
1
import assert from "assert" ;
2
2
import { __query } from "../src/table.js" ;
3
-
4
- function invalidator ( ) {
5
- let invalidate ;
6
- const invalidation = new Promise ( ( resolve ) => ( invalidate = resolve ) ) ;
7
- return [ invalidation , invalidate ] ;
8
- }
3
+ import it , { invalidator } from "./invalidation.js" ;
9
4
10
5
describe ( "__query.sql" , ( ) => {
11
6
it ( "evaluates using db.sql with the expected parameters" , async ( ) => {
You can’t perform that action at this time.
0 commit comments