All files / xstate/test invalid.test.ts

61.9% Statements 13/21
100% Branches 0/0
33.33% Functions 4/12
75% Lines 12/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 491x 1x   1x                                       1x 1x       1x       1x 1x     1x 1x     1x       1x        
import { assert } from 'chai';
import { Machine } from '../src/index';
 
const machine = Machine({
  parallel: true,
  states: {
    A: {
      initial: 'A1',
      states: {
        A1: {},
        A2: {}
      }
    },
    B: {
      initial: 'B1',
      states: {
        B1: {},
        B2: {}
      }
    }
  }
});
 
describe('invalid states', () => {
  xit('should reject transitioning from a String state', () => {
    assert.throws(() => machine.transition('A', 'E'));
  });
 
  xit('should reject transitioning from empty states', () => {
    assert.throws(() => machine.transition({ A: {}, B: {} }, 'E'));
  });
 
  it('should allow transitioning from valid states', () => {
    machine.transition({ A: 'A1', B: 'B1' }, 'E');
  });
 
  it('should reject transitioning from bad state configs', () => {
    assert.throws(() => machine.transition({ A: 'A3', B: 'B3' }, 'E'));
  });
 
  xit('should reject transitioning from partially valid states', () => {
    assert.throws(() => machine.transition({ A: 'A1' }, 'E'));
  });
 
  xit("should reject transitioning from regions that don't exist", () => {
    assert.throws(() => machine.transition({ A: 'A1', B: 'B1', Z: 'Z1' }, 'E'));
  });
});