-
Notifications
You must be signed in to change notification settings - Fork 21
/
forced transitions.spec.ts
26 lines (16 loc) · 1.25 KB
/
forced transitions.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* eslint-disable max-len */
import { sm } from '../jssm';
describe('reject and accept correctly', () => {
const machine = sm` a ~> b -> c; `;
test('starts in a', () => expect( machine.state() ).toBe('a') );
test('rejects transition to b', () => expect( machine.transition('b') ).toBe(false) );
test('still in a', () => expect( machine.state() ).toBe('a') );
test('rejects transition to c', () => expect( machine.transition('c') ).toBe(false) );
test('still in a 2', () => expect( machine.state() ).toBe('a') );
test('rejects forced transition to c', () => expect( machine.force_transition('c') ).toBe(false) );
test('still in a 3', () => expect( machine.state() ).toBe('a') );
test('accepts forced transition to b', () => expect( machine.force_transition('b') ).toBe(true) );
test('now in b', () => expect( machine.state() ).toBe('b') );
test('accepts transition to c', () => expect( machine.transition('c') ).toBe(true) );
test('now in c', () => expect( machine.state() ).toBe('c') );
});