Skip to content

Commit

Permalink
chore: add withMocks function
Browse files Browse the repository at this point in the history
  • Loading branch information
alessbell committed Aug 29, 2024
1 parent d476674 commit 674da60
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,25 @@ function createHandlerFromSchema<TResolvers>(
});
}

function withMocks(mocks: IMocks<TResolvers>) {
const oldSchema = testSchema;

testSchema = addMocksToSchema({
schema: oldSchema,
mocks: mocks,
});

function restore() {
testSchema = oldSchema;
}

return Object.assign(restore, {
[Symbol.dispose]() {
restore();
},
});
}

function replaceDelay(newDelay: Delay) {
const oldDelay = _delay;
_delay = newDelay;
Expand Down Expand Up @@ -269,6 +288,7 @@ function createHandlerFromSchema<TResolvers>(
replaceSchema,
replaceDelay,
withResolvers,
withMocks,
},
);
}
Expand Down

1 comment on commit 674da60

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 95%
94.89% (130/137) 90% (36/40) 85.71% (30/35)
Tests Skipped Failures Errors Time
6 0 💤 0 ❌ 0 🔥 3.466s ⏱️
Coverage Report (95%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files94.899085.7195.52 
   handlers.ts94.3193.7585.7194.18150–163
   utilities.ts95.9187.585.7197.91120

Please sign in to comment.