Created
November 9, 2019 18:02
-
-
Save andrewgordstewart/b9c00f51dd180cad615826d669cf887c to your computer and use it in GitHub Desktop.
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
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