<commit_before>import { createMachine } from '../src';

describe('tags', () => {
  it('supports tagging states', () => {
    const machine = createMachine({
      initial: 'green',
      states: {
        green: {
          tags: ['go']
        },
        yellow: {
          tags: ['go'],
          on: {
            TIMER: 'red'
          }
        },
        red: {
          tags: ['stop']
        }
      }
    });

    expect(machine.initialState.tags.has('go')).toBeTruthy();
    expect(machine.transition('yellow', 'TIMER').tags.has('go')).toBeFalsy();
  });

  it('supports tags in compound states', () => {
    const machine = createMachine({
      initial: 'red',
      states: {
        green: {
          tags: ['go']
        },
        yellow: {},
        red: {
          tags: ['stop'],
          initial: 'walk',
          states: {
            walk: {
              tags: ['crosswalkLight']
            },
            wait: {
              tags: ['crosswalkLight']
            }
          }
        }
      }
    });

    expect(machine.initialState.tags.has('go')).toBeFalsy();
    expect(machine.initialState.tags.has('stop')).toBeTruthy();
    expect(machine.initialState.tags.has('crosswalkLight')).toBeTruthy();
  });

  it('tags can be single (not array)', () => {
    const machine = createMachine({
      initial: 'green',
      states: {
        green: {
          tags: 'go'<commit_msg>Add test for parallel states<commit_after>import { createMachine } from '../src';

describe('tags', () => {
  it('supports tagging states', () => {
    const machine = createMachine({
      initial: 'green',
      states: {
        green: {
          tags: ['go']
        },
        yellow: {
          tags: ['go'],
          on: {
            TIMER: 'red'
          }
        },
        red: {
          tags: ['stop']
        }
      }
    });

    expect(machine.initialState.tags.has('go')).toBeTruthy();
    expect(machine.transition('yellow', 'TIMER').tags.has('go')).toBeFalsy();
  });

  it('supports tags in compound states', () => {
    const machine = createMachine({
      initial: 'red',
      states: {
        green: {
          tags: ['go']
        },
        yellow: {},
        red: {
          tags: ['stop'],
          initial: 'walk',
          states: {
            walk: {
              tags: ['crosswalkLight']
            },
            wait: {
              tags: ['crosswalkLight']
            }
          }
        }
      }
    });

    expect(machine.initialState.tags.has('go')).toBeFalsy();
    expect(machine.initialState.tags.has('stop')).toBeTruthy();
    expect(machine.initialState.tags.has('crosswalkLight')).toBeTruthy();
  });

  it('supports tags in parallel states', () => {
    const machine = createMachine({
      type: 'parallel',
      states: {
        foo: {
          initial: 'active',
          states: {
            active: {
              tags: 'yes'
            },
            inactive: {
              tags: 'no'
            }
          }
        },
        bar: {
          initial: 'active',
          states: {
            active: {
              tags: 'yes',
              on: {
                DEACTIVATE: 'inactive'
              }
            },
            inactive: {
              tags: 'no'
            }
          }
        }
      }
    });

    let state = machine.initialState;

    expect(state.tags).toEqual(new Set(['yes']));
    state = machine.transition(state, 'DEACTIVATE');
    expect(state.tags).toEqual(new Set(['yes', 'no']));
  });

  it('tags can be single (not array)', () => {
    const machine = createMachine({
      initial: 'green',
      states: {
        green: {
          tags: 'go'
{'fraction_non_alphanumeric': 0.16553779463560012, 'fraction_numerical': 0.0, 'mean_word_length': 1.4629753168779187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '5693783', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1063, 'n_words': 196}