<commit_before>import { assert } from 'chai';
import { Machine } from '../src/index';

const lightMachine = Machine({
  key: 'light',
  initial: 'green',
  states: {
    green: {
      on: {
        TIMER: 'yellow'
      }
    },
    yellow: {
      on: {
        TIMER: 'red'
      }
    },
    red: {
      initial: 'walk',
      activities: ['activateCrosswalkLight'],
      on: {
        TIMER: 'green'
      },
      states: {
        walk: { on: { PED_WAIT: 'wait' } },
        wait: {
          activities: ['blinkCrosswalkLight'],
          on: { PED_STOP: 'stop' }
        },
        stop: {}
      }
    }
  }
});

describe('activities', () => {
  it('identifies start activities', () => {
    assert.deepEqual(lightMachine.transition('yellow', 'TIMER').activities, {
      activateCrosswalkLight: true
    });
  });

  it('identifies start activities for child states and active activities', () => {
    const redWalkState = lightMachine.transition('yellow', 'TIMER');
    assert.deepEqual(
      lightMachine.transition(redWalkState, 'PED_WAIT').activities,
      {
        activateCrosswalkLight: true,
        blinkCrosswalkLight: true
      }
    );
  });

  it('identifies stop activities for child states', () => {
    const redWalkState = lightMachine.transition('yellow', 'TIMER');
    const redWaitState = lightMachine.transition(redWalkState, 'PED_WAIT');

    assert.deepEqual(
      lightMachine.transition(redWaitState, 'PED_STOP').activities,
      {
        activateCrosswalkLight: true,
        blinkCrosswalkLight: false
      }
    );
  });

  it('identifies multiple stop activities for child and parent states', () => {
    const redWalkState = lightMachine.transition('yellow', 'TIMER');
    const redWaitState = lightMachine.transition(redWalkState, 'PED_WAIT');
    const redStopState = lightMachine.transition(redWaitState, 'PED_STOP');

    console.log(
      redStopState.value,
      lightMachine.transition(redStopState, 'TIMER').value
    );

    assert.deepEqual(
      lightMachine.transition(redStopState, 'TIMER').activities,
      {
        activateCrosswalkLight: false,
        blinkCrosswalkLight: false
      }
    );
  });
});<commit_msg>Remove console log<commit_after>import { assert } from 'chai';
import { Machine } from '../src/index';

const lightMachine = Machine({
  key: 'light',
  initial: 'green',
  states: {
    green: {
      on: {
        TIMER: 'yellow'
      }
    },
    yellow: {
      on: {
        TIMER: 'red'
      }
    },
    red: {
      initial: 'walk',
      activities: ['activateCrosswalkLight'],
      on: {
        TIMER: 'green'
      },
      states: {
        walk: { on: { PED_WAIT: 'wait' } },
        wait: {
          activities: ['blinkCrosswalkLight'],
          on: { PED_STOP: 'stop' }
        },
        stop: {}
      }
    }
  }
});

describe('activities', () => {
  it('identifies start activities', () => {
    assert.deepEqual(lightMachine.transition('yellow', 'TIMER').activities, {
      activateCrosswalkLight: true
    });
  });

  it('identifies start activities for child states and active activities', () => {
    const redWalkState = lightMachine.transition('yellow', 'TIMER');
    assert.deepEqual(
      lightMachine.transition(redWalkState, 'PED_WAIT').activities,
      {
        activateCrosswalkLight: true,
        blinkCrosswalkLight: true
      }
    );
  });

  it('identifies stop activities for child states', () => {
    const redWalkState = lightMachine.transition('yellow', 'TIMER');
    const redWaitState = lightMachine.transition(redWalkState, 'PED_WAIT');

    assert.deepEqual(
      lightMachine.transition(redWaitState, 'PED_STOP').activities,
      {
        activateCrosswalkLight: true,
        blinkCrosswalkLight: false
      }
    );
  });

  it('identifies multiple stop activities for child and parent states', () => {
    const redWalkState = lightMachine.transition('yellow', 'TIMER');
    const redWaitState = lightMachine.transition(redWalkState, 'PED_WAIT');
    const redStopState = lightMachine.transition(redWaitState, 'PED_STOP');

    assert.deepEqual(
      lightMachine.transition(redStopState, 'TIMER').activities,
      {
        activateCrosswalkLight: false,
        blinkCrosswalkLight: false
      }
    );
  });
});
{'fraction_non_alphanumeric': 0.1379068133926481, 'fraction_numerical': 0.0, 'mean_word_length': 2.6732588134135855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1038615', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1255, 'n_words': 248}