Skip to content

Instantly share code, notes, and snippets.

View mattpocock's full-sized avatar

Matt Pocock mattpocock

View GitHub Profile
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@mattpocock
mattpocock / machine.js
Last active June 25, 2021 08:26
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@mattpocock
mattpocock / machine.js
Last active May 6, 2021 14:15
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
import produce from 'immer';
export const mockVariableForEachTest = <T>(
initial: T,
): [() => T, (func: (mock: T) => void) => void] => {
let variable = initial;
const modify = (func: (variable: T) => void) => {
variable = produce(variable, func);
};
describeFeature('getUsers', (getUsers) => {
getUsers.test('scenarioName', () => {});
getUsers.test('otherScenarioName', () => {});
getUsers.coverage();
});
const endpointToPromiseMap = {
[ApiEndpoint.FetchAllGoals]: fetchUserGoals,
[ApiEndpoint.CurrentUser]: currentUser,
};
type PromiseValue<T extends Promise<any>> = T extends Promise<infer U>
? U
: never;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types