-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11806 from apollographql/pr/mockLink-defaults
MockLink: add query default variables if not specified in mock request
- Loading branch information
Showing
5 changed files
with
121 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@apollo/client": patch | ||
--- | ||
|
||
MockLink: add query default variables if not specified in mock request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { withCleanup } from "./withCleanup.js"; | ||
|
||
declare global { | ||
interface DateConstructor { | ||
/* Jest uses @sinonjs/fake-timers, that add this flag */ | ||
isFake: boolean; | ||
} | ||
} | ||
|
||
export function enableFakeTimers( | ||
config?: FakeTimersConfig | LegacyFakeTimersConfig | ||
) { | ||
if (global.Date.isFake === true) { | ||
// Nothing to do here, fake timers have already been set up. | ||
// That also means we don't want to clean that up later. | ||
return withCleanup({}, () => {}); | ||
} | ||
|
||
jest.useFakeTimers(config); | ||
return withCleanup({}, () => { | ||
if (global.Date.isFake === true) { | ||
jest.runOnlyPendingTimers(); | ||
jest.useRealTimers(); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { disableActWarnings } from "./disableActWarnings.js"; | ||
export { spyOnConsole } from "./spyOnConsole.js"; | ||
export { withCleanup } from "./withCleanup.js"; | ||
export { enableFakeTimers } from "./enableFakeTimers.js"; |