Skip to content

Instantly share code, notes, and snippets.

@oscargm
Created June 12, 2020 07:34
Show Gist options
  • Save oscargm/3b82ab66d55b50dc0a0f60ffed7eeaf8 to your computer and use it in GitHub Desktop.
Save oscargm/3b82ab66d55b50dc0a0f60ffed7eeaf8 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const resizableBoxMachine = Machine({
id: 'resizable-box',
initial: 'restored',
states: {
restored: {
on: {
MINIMIZE: {
target: 'minimized',
actions: 'minimize',
},
MAXIMIZE: {
target: 'maximized',
actions: 'maximize',
},
},
meta: {
test: ({ getByTestId }) => {
expect(getByTestId('icon-minimize')).not.toBeNull();
expect(getByTestId('icon-maximize')).not.toBeNull();
},
},
},
maximized: {
on: {
MINIMIZE: {
target: 'restored',
actions: 'restore',
},
},
meta: {
test: ({ getByTestId }) => {
expect(getByTestId('icon-minimize')).not.toBeNull();
expect(getByTestId('icon-maximize')).toBeNull();
},
},
},
minimized: {
on: {
MAXIMIZE: {
target: 'restored',
actions: 'restore',
},
},
meta: {
test: ({ getByTestId }) => {
expect(getByTestId('icon-maximize')).not.toBeNull();
expect(getByTestId('icon-minimize')).toBeNull();
},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment