<commit_before>'use strict';

const test = require('tape'),
    prune = require('../utils/prune');

test('pruning invalid data should result in an error',
    (t) => {
        t.plan(2);
        const data = {
                some: 'invalid data'
            },
            err = prune(data);

        t.equal(
            typeof (err), 'object',
            'Error should be an error object.'
        );
        t.equal(
            err.message, 'Data does not match any pruneable type.',
            'Error object should have a message.'
        );
        t.end();
    });

test('prune(search_player_all) should return an array of pruned search results',
    (t) => {
        t.plan(6);
        let data, pruned, expectedLength;

        data = require('./mock/search_player_all.json');
        pruned = prune(data);
        expectedLength = +data.search_player_all.queryResults.totalSize;

        t.true(
            Array.isArray(pruned),
            'Pruned should be an array.'
        );
        t.true(
            pruned[0].hasOwnProperty('name'),
            'A pruned result should have `name` property.'
        );
        t.equal(
            expectedLength, pruned.length,
            `Expected array length to be ${expectedLength}, but it was ${pruned.length}`
        );

        data = require('./mock/search_player_all.single.json');
        pruned = prune(data);
        expectedLength = +data.search_player_all.queryResults.totalSize;

        t.true(
            Array.isArray(pruned),
            'Pruned should be an array.'
        );
        t.true(
            pruned[0].hasOwnProperty('name'),
            'A pruned result should have `name` property.'
        );
        t.equal(
            expectedLength, pruned.length,
            `Expected array length to be ${expectedLength}, but it was ${pruned.length}`
        );

        t.end();
    });

test('prune(roster_40) should return an array of pruned players',
    (t) => {
        t.plan(6);
        let data, pruned, expectedLength;

        data = require('./mock/roster_40.json');
        pruned = prune(data);
        expectedLength = +data.roster_40.queryResults.totalSize;

        t.true(
            Array.isArray(pruned),
            'Pruned should be an array.'
        );
        t.true(
            pruned[0].hasOwnProperty('attribute'),
            'A pruned roster entry should have an `attribute` property.'
        );
        t.equal(
            expectedLength, pruned.length,
            `Expected array length to be ${expectedLength}, but it was ${pruned.length}`
        );

        data = require('./mock/roster_40.short.json');
        pruned = prune(data);
        expectedLength = +data.roster_40.queryResults.totalSize;

        t.true(
            Array.isArray(pruned),
            'Pruned should be an array.'
        );
        t.true(
            pruned[0].hasOwnProperty('name'),
            'A pruned short roster entry should have an `name` property.'
        );
        t.equal(
            expectedLength, pruned.length,
            `Expected array length to be ${expectedLength}, but it was ${pruned.length}`
        );

        t.end();
    });

test('prune(player_info) should return a pruned player object',
    (t) => {
        t.plan(2);
        let data, pruned;

        data = require('./mock/player_info.json');
        pruned = prune(data);

        t.equal(
            typeof (pruned), 'object',
            'Pruned player should be an object.'
        );
        t.true(
            pruned.hasOwnProperty('attribute'),
            'A pruned player should have `attribute` property.'
        );
        t.end();
    });

test('prune(sport_hitting_tm) should return an array of pruned hitting stats',
    (t) => {
        t.plan(6);
        let data, pruned, expectedLength;

        data = require('./mock/sport_hitting_tm.json');
        pruned = prune(data);
        expectedLength = +data.sport_hitting_tm.queryResults.totalSize;
        
<commit_msg>whitespace<commit_after>'use strict';

const test = require('tape'),
    prune = require('../utils/prune');

test('pruning invalid data should result in an error',
    (t) => {
        t.plan(2);
        const data = {
                some: 'invalid data'
            },
            err = prune(data);

        t.equal(
            typeof (err), 'object',
            'Error should be an error object.'
        );
        t.equal(
            err.message, 'Data does not match any pruneable type.',
            'Error object should have a message.'
        );
        t.end();
    });

test('prune(search_player_all) should return an array of pruned search results',
    (t) => {
        t.plan(6);
        let data, pruned, expectedLength;

        data = require('./mock/search_player_all.json');
        pruned = prune(data);
        expectedLength = +data.search_player_all.queryResults.totalSize;

        t.true(
            Array.isArray(pruned),
            'Pruned should be an array.'
        );
        t.true(
            pruned[0].hasOwnProperty('name'),
            'A pruned result should have `name` property.'
        );
        t.equal(
            expectedLength, pruned.length,
            `Expected array length to be ${expectedLength}, but it was ${pruned.length}`
        );

        data = require('./mock/search_player_all.single.json');
        pruned = prune(data);
        expectedLength = +data.search_player_all.queryResults.totalSize;

        t.true(
            Array.isArray(pruned),
            'Pruned should be an array.'
        );
        t.true(
            pruned[0].hasOwnProperty('name'),
            'A pruned result should have `name` property.'
        );
        t.equal(
            expectedLength, pruned.length,
            `Expected array length to be ${expectedLength}, but it was ${pruned.length}`
        );

        t.end();
    });

test('prune(roster_40) should return an array of pruned players',
    (t) => {
        t.plan(6);
        let data, pruned, expectedLength;

        data = require('./mock/roster_40.json');
        pruned = prune(data);
        expectedLength = +data.roster_40.queryResults.totalSize;

        t.true(
            Array.isArray(pruned),
            'Pruned should be an array.'
        );
        t.true(
            pruned[0].hasOwnProperty('attribute'),
            'A pruned roster entry should have an `attribute` property.'
        );
        t.equal(
            expectedLength, pruned.length,
            `Expected array length to be ${expectedLength}, but it was ${pruned.length}`
        );

        data = require('./mock/roster_40.short.json');
        pruned = prune(data);
        expectedLength = +data.roster_40.queryResults.totalSize;

        t.true(
            Array.isArray(pruned),
            'Pruned should be an array.'
        );
        t.true(
            pruned[0].hasOwnProperty('name'),
            'A pruned short roster entry should have an `name` property.'
        );
        t.equal(
            expectedLength, pruned.length,
            `Expected array length to be ${expectedLength}, but it was ${pruned.length}`
        );

        t.end();
    });

test('prune(player_info) should return a pruned player object',
    (t) => {
        t.plan(2);
        let data, pruned;

        data = require('./mock/player_info.json');
        pruned = prune(data);

        t.equal(
            typeof (pruned), 'object',
            'Pruned player should be an object.'
        );
        t.true(
            pruned.hasOwnProperty('attribute'),
            'A pruned player should have `attribute` property.'
        );
        t.end();
    });

test('prune(sport_hitting_tm) should return an array of pruned hitting stats',
    (t) => {
        t.plan(6);
        let data, pruned, expectedLength;

        data = require('./mock/sport_hitting_tm.json');
        pruned = prune(data);
        expectedLength = +data.sport_hitting_tm.queryResults.totalSize;

{'fraction_non_alphanumeric': 0.12430939226519337, 'fraction_numerical': 0.004771471622300351, 'mean_word_length': 1.784965034965035, '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': '4359963', 'n_tokens_mistral': 2367, 'n_tokens_neox': 2264, 'n_words': 566}