<commit_before>/*jshint strict:false */
/*globals describe, it */

var formatGreeting,
    assert = require('chai').assert,
    fillopts = require('../index');


formatGreeting = function (opts, punctuation) {
    return 'Hello, ' + opts.title + ' ' + opts.name + punctuation;
};


describe('fillopts', function () {
    it('fills opts', function () {
        var filled = fillopts(formatGreeting, {title: 'Dr.', name: 'Crusher'});
        assert.equal(filled(), 'Hello, Dr. Crusher');
    });
    it('preserves args', function () {
        var filled = fillopts(formatGreeting, {title: 'Dr.', name: 'Crusher'});
        assert.equal(filled(null, '!'), 'Hello, Dr. Crusher!');
    });
    it('combines filled opts', function () {
        var filled = fillopts(
            fillopts(formatGreeting, {title: 'Dr.'}),
            {name: 'Crusher'}
        );
        assert.equal(filled(), 'Hello, Dr. Crusher');
    });
    it('overrides previous opts', function () {
        var filled = fillopts(
            fillopts(formatGreeting, {title: 'Dr.'}, {name: 'Crusher'}),
            {name: 'Pulaski'}
        );
        assert.equal(filled(), 'Hello, Dr. Pulaski');
    });
    it("doesn't mutate the old function", function () {
        var filledA = fillopts(formatGreeting, {title: 'Dr.', name: 'Pulaski'}),
            filledB = fillopts(filledA, {name: 'Crusher'});
        assert.equal(filledA(), 'Hello, Dr. Pulaski');
        assert.equal(filledB(), 'Hello, Dr. Crusher');
    });

    describe('withOpts', function () {
        it('adds opts', function () {
            var filled = fillopts(formatGreeting)
                .withOpts({title: 'Dr.', name: 'Crusher'});
            assert.equal(filled(), 'Hello, Dr. Crusher');
        });
        it('combines filled opts', function () {
            var filled = fillopts(formatGreeting)
                .withOpts({title: 'Dr.'})
                .withOpts({name: 'Crusher'});
            assert.equal(filled(), 'Hello, Dr. Crusher');
        });
        it('overrides previous opts', function () {
            var filled = fillopts(formatGreeting)
                .withOpts({title: 'Dr.'}, {name: 'Crusher'})
                .withOpts({name: 'Pulaski'});
            assert.equal(filled(), 'Hello, Dr. Pulaski');
        });
        it("doesn't mutate the old function", function () {
            var filledA = fillopts(formatGreeting, {title: 'Dr.', name: 'Pulaski'}),
                filledB = filledA.withOpts({name: 'Crusher'});
            assert.equal(filledA(), 'Hello, Dr. Pulaski');
            assert.equal(filledB(), 'Hello, Dr. Crusher');
        });
    });
});
<commit_msg>Fix bad tests<commit_after>/*jshint strict:false */
/*globals describe, it */

var formatGreeting,
    assert = require('chai').assert,
    fillopts = require('../index');


formatGreeting = function (opts, punctuation) {
    return 'Hello, ' + opts.title + ' ' + opts.name + (punctuation || '');
};


describe('fillopts', function () {
    it('fills opts', function () {
        var filled = fillopts(formatGreeting, {title: 'Dr.', name: 'Crusher'});
        assert.equal(filled(), 'Hello, Dr. Crusher');
    });
    it('preserves args', function () {
        var filled = fillopts(formatGreeting, {title: 'Dr.', name: 'Crusher'});
        assert.equal(filled(null, '!'), 'Hello, Dr. Crusher!');
    });
    it('combines filled opts', function () {
        var filled = fillopts(
            fillopts(formatGreeting, {title: 'Dr.'}),
            {name: 'Crusher'}
        );
        assert.equal(filled(), 'Hello, Dr. Crusher');
    });
    it('overrides previous opts', function () {
        var filled = fillopts(
            fillopts(formatGreeting, {title: 'Dr.', name: 'Crusher'}),
            {name: 'Pulaski'}
        );
        assert.equal(filled(), 'Hello, Dr. Pulaski');
    });
    it("doesn't mutate the old function", function () {
        var filledA = fillopts(formatGreeting, {title: 'Dr.', name: 'Pulaski'}),
            filledB = fillopts(filledA, {name: 'Crusher'});
        assert.equal(filledA(), 'Hello, Dr. Pulaski');
        assert.equal(filledB(), 'Hello, Dr. Crusher');
    });

    describe('withOpts', function () {
        it('adds opts', function () {
            var filled = fillopts(formatGreeting)
                .withOpts({title: 'Dr.', name: 'Crusher'});
            assert.equal(filled(), 'Hello, Dr. Crusher');
        });
        it('combines filled opts', function () {
            var filled = fillopts(formatGreeting)
                .withOpts({title: 'Dr.'})
                .withOpts({name: 'Crusher'});
            assert.equal(filled(), 'Hello, Dr. Crusher');
        });
        it('overrides previous opts', function () {
            var filled = fillopts(formatGreeting)
                .withOpts({title: 'Dr.', name: 'Crusher'})
                .withOpts({name: 'Pulaski'});
            assert.equal(filled(), 'Hello, Dr. Pulaski');
        });
        it("doesn't mutate the old function", function () {
            var filledA = fillopts(formatGreeting, {title: 'Dr.', name: 'Pulaski'}),
                filledB = filledA.withOpts({name: 'Crusher'});
            assert.equal(filledA(), 'Hello, Dr. Pulaski');
            assert.equal(filledB(), 'Hello, Dr. Crusher');
        });
    });
});

{'fraction_non_alphanumeric': 0.18027210884353742, 'fraction_numerical': 0.0, 'mean_word_length': 2.3521215959468016, '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': '6762672', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1624, 'n_words': 364}