<commit_before>import { buildAction, getType, ActionsUnion } from './';

describe('buildAction', () => {

  // TODO: #3
  // should error when missing argument
  // should error when passed invalid arguments
  // check object, empty array, primitives

  it('no payload', () => {
    const increment = buildAction('INCREMENT').empty();
    const action: { type: 'INCREMENT' } = increment();
    expect(action).toEqual({ type: 'INCREMENT' });
    const type: 'INCREMENT' = getType(increment);
    expect(type).toBe('INCREMENT');
  });

  it('no payload alternative', () => {
    const increment = buildAction('INCREMENT').payload<void>();
    const action: { type: 'INCREMENT' } = increment();
    expect(action).toEqual({ type: 'INCREMENT' });
    const type: 'INCREMENT' = getType(increment);
    expect(type).toBe('INCREMENT');
  });

  it('with payload', () => {
    const add = buildAction('ADD').payload<number>();
    const action: { type: 'ADD'; payload: number } = add(10);
    expect(action).toEqual({ type: 'ADD', payload: 10 });
    const type: 'ADD' = getType(add);
    expect(type).toBe('ADD');
  });
<commit_msg>Added test for boolean payload<commit_after>import { buildAction, getType, ActionsUnion } from './';

describe('buildAction', () => {

  // TODO: #3
  // should error when missing argument
  // should error when passed invalid arguments
  // check object, empty array, primitives

  it('no payload', () => {
    const increment = buildAction('INCREMENT').empty();
    const action: { type: 'INCREMENT' } = increment();
    expect(action).toEqual({ type: 'INCREMENT' });
    const type: 'INCREMENT' = getType(increment);
    expect(type).toBe('INCREMENT');
  });

  it('no payload alternative', () => {
    const increment = buildAction('INCREMENT').payload<void>();
    const action: { type: 'INCREMENT' } = increment();
    expect(action).toEqual({ type: 'INCREMENT' });
    const type: 'INCREMENT' = getType(increment);
    expect(type).toBe('INCREMENT');
  });

  it('with payload', () => {
    const add = buildAction('ADD').payload<number>();
    const action: { type: 'ADD'; payload: number } = add(10);
    expect(action).toEqual({ type: 'ADD', payload: 10 });
    const type: 'ADD' = getType(add);
    expect(type).toBe('ADD');
  });
  
  it('with boolean payload', () => {
    const set = buildAction('SET').payload<boolean>();
    const action: { type: 'SET'; payload: boolean } = set(true);
    expect(action).toEqual({ type: 'SET', payload: true });
    const type: 'SET' = getType(set);
    expect(type).toBe('SET');
  });

{'fraction_non_alphanumeric': 0.1901600937133932, 'fraction_numerical': 0.003904724716907458, 'mean_word_length': 3.9080459770114944, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 17, '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': '2850154', 'n_tokens_mistral': 790, 'n_tokens_neox': 776, 'n_words': 193}