Skip to content

Instantly share code, notes, and snippets.

@andrewgordstewart
Created November 9, 2019 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewgordstewart/b9c00f51dd180cad615826d669cf887c to your computer and use it in GitHub Desktop.
Save andrewgordstewart/b9c00f51dd180cad615826d669cf887c to your computer and use it in GitHub Desktop.
interface ToggleMachineState {
states: {
inactive: {};
active: {};
};
}
type ToggleEvent = { type: 'TOGGLE' };
type ToggleMachineConfig = MachineConfig<
undefined,
ToggleMachineState,
ToggleEvent
>;
const toggleMachineConfig: ToggleMachineConfig = {
id: 'toggle',
initial: 'inactive',
states: {
inactive: {
on: {
TOGGLE: 'active'
}
},
active: {
on: {
TOGGLE: 'inactive'
}
}
}
};
const testCases: ToggleMachineConfig = {
states: {
inactive: {
meta: {
test: async page => {
await page.waitFor('input:checked');
}
}
},
active: {
meta: {
test: async page => {
await page.waitFor('input:checked');
}
}
}
}
};
const testConfig = merge(toggleMachineConfig, testCases);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment