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

describe('reactabular-column-extensions.bind', function () {
  it('returns the same structure without extensions', function () {
    const extensions = [];
    const columns = [
      {}
    ];

    expect(bind(extensions)(columns)).toEqual(columns);
  });

  it('matches and merges an extension', function () {
    const extensions = [
      {
        match({ cell }) {
          return cell.ok;
        },
        evaluate() {
          return {
            cell: {
              evaluated: true
            }
          };
        }
      }
    ];
    const columns = [
      {
        cell: {
          ok: true
        }
      }
    ];
    const expected = [
      {
        cell: {
          ok: true,
          evaluated: true
        }
      }
    ];

    expect(bind(extensions)(columns)).toEqual(expected);
  });

  it('passes column to evaluator', function () {
    const extensions = [
      {
        match({ cell }) {
          return cell.ok;
        },
        evaluate({ cell: { ok } }) {
          return {
            cell: {
              ok: ok + ok
            }
          };
        }
      }
    ];
    const columns = [
      {
        cell: {
          ok: 'foo'
        }
      }
    ];
    const expected = [
      {
        cell: {
          ok: 'foofoo'
        }
      }
    ];

    expect(bind(extensions)(columns)).toEqual(expected);
  });

  it('works with multiple evaluators', function () {
    const extensions = [
      {
        match({ cell }) {
          return cell.ok;
        },
        evaluate() {
          return {
            cell: {
              evaluated: true
            }
          };
        }
      },
      {
        match({ cell }) {
          return cell.ok;
        },
        evaluate() {
          return {
            cell: {
              evaluatedAgain: true
            }
          };
        }
      }
    ];
    const columns = [
      {
        cell: {<commit_msg>chore - Add a sanity check<commit_after>import { bind } from '../src';

describe('reactabular-column-extensions.bind', function () {
  it('returns the same structure without extensions', function () {
    const extensions = [];
    const columns = [
      {}
    ];

    expect(bind(extensions)(columns)).toEqual(columns);
  });

  it('matches and merges an extension', function () {
    const extensions = [
      {
        match({ cell }) {
          return cell.ok;
        },
        evaluate() {
          return {
            cell: {
              evaluated: true
            }
          };
        }
      }
    ];
    const columns = [
      {
        cell: {
          ok: true
        }
      }
    ];
    const expected = [
      {
        cell: {
          ok: true,
          evaluated: true
        }
      }
    ];

    expect(bind(extensions)(columns)).toEqual(expected);
  });

  it('passes column to evaluator', function () {
    const extensions = [
      {
        match({ cell }) {
          return cell.ok;
        },
        evaluate({ cell: { ok } }) {
          return {
            cell: {
              ok: ok + ok
            }
          };
        }
      }
    ];
    const columns = [
      {
        cell: {
          ok: 'foo'
        }
      }
    ];
    const expected = [
      {
        cell: {
          ok: 'foofoo'
        }
      }
    ];

    expect(bind(extensions)(columns)).toEqual(expected);
  });

  it('retains a function', function () {
    const extensions = [
      {
        match({ cell }) {
          return cell.ok;
        },
        evaluate({ cell: { ok } }) {
          return {
            cell: {
              ok: ok + ok
            }
          };
        }
      }
    ];
    const columns = [
      {
        cell: {
          ok: 'foo',
          formatters: [
            () => 'a'
          ]
        }
      }
    ];
    const expected = [
      {
        cell: {
          ok: 'foofoo'
        }
      }
    ];
    const result = bind(extensions)(columns);
    const formatters = result[0].cell.formatters;

    delete result[0].cell.formatters;

    expect(result).toEqual(expected);
    expect(formatters[0]()).toEqual('a');
  });

  it('works with multiple evaluators', function () {
    const extensions = [
      {
        match({ cell }) {
          return cell.ok;
        },
        evaluate() {
          return {
            cell: {
              evaluated: true
            }
          };
        }
      },
      {
        match({ cell }) {
          return cell.ok;
        },
        evaluate() {
          return {
            cell: {
              evaluatedAgain: true
            }
          };
        }
      }
    ];
    const columns = [
      {
        cell: {
{'fraction_non_alphanumeric': 0.13186813186813187, 'fraction_numerical': 0.0006339814032121725, 'mean_word_length': 1.0650087260034904, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3704646', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1315, 'n_words': 256}