<commit_before>var assert = require('chai').assert;
var collection = require('../index.js');

describe('plugin', function(){

    var plugin = collection('test', [function(pages){

        pages.push('a');

        return Promise.resolve(pages);
    }]);

    it('should act on all desired properties as if they are pages', function(done){

        plugin([{}, {}, {}]).then(function(pages){

            assert.deepEqual(pages, [ { test: ['a'] }, { test: ['a'] }, { test: ['a'] } ]);

            done();
        });
    });

    it('should append to existing property that is an array', function(done){

        plugin([{test: ['b']}]).then(function(pages){

            assert.deepEqual(pages, [ { test: ['b', 'a'] } ]);

            done();
        });
    });

    it('should replace existing property that is not an array', function(done){

        plugin([{test: 'a'}]).then(function(pages){

            assert.deepEqual(pages, [ { test: ['a'] } ]);

            done();
        });
    });
});
<commit_msg>Improve tests<commit_after>var assert = require('chai').assert;
var collection = require('../index.js');

describe('plugin', function(){

    var plugin = collection('test', [function(pages){

        pages.push('a');

        return Promise.resolve(pages);
    }]);

    it('should act on all desired properties as if they are pages', function(done){

        plugin([{}, {}, {}]).then(function(pages){

            assert.deepEqual(pages, [ { test: ['a'] }, { test: ['a'] }, { test: ['a'] } ]);

            done();
        })
        .catch(done);
    });

    it('should append to existing property that is an array', function(done){

        plugin([{test: ['b']}]).then(function(pages){

            assert.deepEqual(pages, [ { test: ['b', 'a'] } ]);

            done();
        })
        .catch(done);
    });

    it('should replace existing property that is not an array', function(done){

        plugin([{test: 'a'}]).then(function(pages){

            assert.deepEqual(pages, [ { test: ['a'] } ]);

            done();
        })
        .catch(done);
    });
});

{'fraction_non_alphanumeric': 0.2040133779264214, 'fraction_numerical': 0.0, 'mean_word_length': 2.3665594855305465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4459283', 'n_tokens_mistral': 627, 'n_tokens_neox': 591, 'n_words': 144}