2019-09-25 21:01:21 +02:00
|
|
|
/* eslint-env jest */
|
|
|
|
import { imgSnapshotTest } from '../../helpers/util';
|
|
|
|
|
|
|
|
describe('State diagram', () => {
|
|
|
|
it('should render a simple state diagrams', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
stateDiagram
|
|
|
|
[*] --> State1
|
|
|
|
State1 --> [*]
|
|
|
|
`,
|
|
|
|
{ logLevel: 0 }
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
2019-10-05 12:15:14 +02:00
|
|
|
});
|
2019-10-06 10:52:37 +02:00
|
|
|
it('should render a state with a note', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
stateDiagram
|
|
|
|
State1: The state with a note
|
|
|
|
note right of State1
|
|
|
|
Important information! You can write
|
|
|
|
notes.
|
|
|
|
end note
|
|
|
|
`,
|
|
|
|
{ logLevel: 0 }
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
|
|
|
it('should render a state with on the left side when so specified', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
stateDiagram
|
|
|
|
State1: The state with a note
|
|
|
|
note left of State1
|
|
|
|
Important information! You can write
|
|
|
|
notes.
|
|
|
|
end note
|
|
|
|
`,
|
|
|
|
{ logLevel: 0 }
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
|
|
|
it('should render a state with a note together with another state', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
stateDiagram
|
|
|
|
State1: The state with a note
|
|
|
|
note right of State1
|
|
|
|
Important information! You can write
|
|
|
|
notes.
|
|
|
|
end note
|
|
|
|
State1 --> State2
|
|
|
|
`,
|
|
|
|
{ logLevel: 0 }
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-10-05 12:15:14 +02:00
|
|
|
it('should render a states with descriptions including multi-line descriptions', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
stateDiagram
|
|
|
|
State1: This a a single line description
|
|
|
|
State2: This a a multi line description
|
|
|
|
State2: here comes the multi part
|
|
|
|
[*] --> State1
|
|
|
|
State1 --> State2
|
|
|
|
State2 --> [*]
|
|
|
|
`,
|
|
|
|
{ logLevel: 0 }
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
2019-09-25 21:01:21 +02:00
|
|
|
});
|
2019-09-28 13:31:10 +02:00
|
|
|
it('should render a simple state diagrams', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
stateDiagram
|
|
|
|
[*] --> State1
|
|
|
|
State1 --> State2
|
|
|
|
State1 --> State3
|
|
|
|
State1 --> [*]
|
|
|
|
`,
|
|
|
|
{ logLevel: 0 }
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
|
|
|
it('should render a simple state diagrams with labels', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
stateDiagram
|
|
|
|
[*] --> State1
|
|
|
|
State1 --> State2 : Transition 1
|
|
|
|
State1 --> State3 : Transition 2
|
|
|
|
State1 --> State4 : Transition 3
|
|
|
|
State1 --> State5 : Transition 4
|
|
|
|
State2 --> State3 : Transition 5
|
|
|
|
State1 --> [*]
|
|
|
|
`,
|
|
|
|
{ logLevel: 0 }
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-09-29 15:50:43 +02:00
|
|
|
it('should render state descriptions', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
stateDiagram
|
|
|
|
state "Long state description" as XState1
|
|
|
|
state "Another Long state description" as XState2
|
|
|
|
XState2 : New line
|
2019-10-02 19:32:13 +02:00
|
|
|
XState1 --> XState2
|
|
|
|
`,
|
|
|
|
{ logLevel: 0 }
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
|
|
|
it('should render composit states', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
stateDiagram
|
2019-10-03 19:08:15 +02:00
|
|
|
[*] --> NotShooting: Pacifist
|
|
|
|
NotShooting --> A
|
|
|
|
NotShooting --> B
|
|
|
|
NotShooting --> C
|
2019-10-02 19:32:13 +02:00
|
|
|
|
|
|
|
state NotShooting {
|
2019-10-03 19:08:15 +02:00
|
|
|
[*] --> Idle: Yet another long long öong öong öong label
|
2019-10-02 19:32:13 +02:00
|
|
|
Idle --> Configuring : EvConfig
|
2019-10-03 19:08:15 +02:00
|
|
|
Configuring --> Idle : EvConfig EvConfig EvConfig EvConfig EvConfig
|
2019-10-02 19:32:13 +02:00
|
|
|
}
|
2019-09-29 15:50:43 +02:00
|
|
|
`,
|
|
|
|
{ logLevel: 0 }
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-10-03 19:54:07 +02:00
|
|
|
it('should render multiple composit states', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
stateDiagram
|
|
|
|
[*]-->TV
|
2019-10-05 09:02:20 +02:00
|
|
|
|
2019-10-03 19:54:07 +02:00
|
|
|
state TV {
|
|
|
|
[*] --> Off: Off to start with
|
|
|
|
On --> Off : Turn off
|
|
|
|
Off --> On : Turn on
|
|
|
|
}
|
2019-10-05 09:02:20 +02:00
|
|
|
|
|
|
|
TV--> Console : KarlMartin
|
|
|
|
|
2019-10-03 19:54:07 +02:00
|
|
|
state Console {
|
|
|
|
[*] --> Off2: Off to start with
|
|
|
|
On2--> Off2 : Turn off
|
|
|
|
Off2 --> On2 : Turn on
|
|
|
|
On2-->Playing
|
|
|
|
|
|
|
|
state Playing {
|
|
|
|
Alive --> Dead
|
|
|
|
Dead-->Alive
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{ logLevel: 0 }
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-09-25 21:01:21 +02:00
|
|
|
});
|