<commit_before>'use strict';
var _ = require('lodash'),
    assert = require('chai').assert,

    Browser = require('../lib/browser'),
    suiteUtil = require('../lib/suite-util'),

    shouldSkip = suiteUtil.shouldSkip,
    flattenSuites = suiteUtil.flattenSuites;

describe('suite-util', function() {
    describe('shouldSkip()', function() {
        function makeBrowser(capabilities) {
            var config = {
                browsers: {id: capabilities}
            };
            return new Browser(config, 'id');
        }

        it('should not skip any browser if skipped=false', function() {
            shouldSkip(false, makeBrowser({browserName: 'browser'})).must.be.false();
        });

        it('should skip any browser if skipped=true', function() {
            shouldSkip(true, makeBrowser({browserName: 'browser'})).must.be.true();
        });

        it('should skip browser if its name and version matches skip list', function() {
            shouldSkip(
                [{browserName: 'browser', version: '1.0'}],
                makeBrowser({browserName: 'browser', version: '1.0'})
            ).must.be.true();
        });

        it('should not skip the browser if its name does not match skip list', function() {
            shouldSkip(
                [{browserName: 'browser', version: '1.0'}],
                makeBrowser({browserName: 'other browser', version: '1.0'})
            ).must.be.false();
        });

        it('should not skip browser if its version does not match skip list', function() {
            shouldSkip(
                [{browserName: 'browser', version: '1.0'}],
                makeBrowser({browserName: 'browser', version: '1.1'})
            ).must.be.false();
        });

        it('should skip any browser of a given name if version is not specified in skip list', function() {
            shouldSkip(
                [{browserName: 'browser'}],
                makeBrowser({browserName: 'browser', version: '1.1'})
            ).must.be.true();
        });
    });

    describe('flattenSuites()', function() {
        var root;

        function addChildTo(parent) {
            var child = {};
            parent.children = (parent.children || []).concat(child);
            return child;
        }

        function addGrandNthChild(n, parent) {
            var result = addChildTo;
            while (n-- > 1) {
                result = _.compose(addChildTo, result);
            }
            return result(parent);
        }

        beforeEach(function() {
            root = {name: 'root'};
        });

        it('should return an array when root is falsey', function() {
            assert.isArray(flattenSuites());
        });

        it('should return an empty array when root is falsey', function() {
            assert.lengthOf(flattenSuites(), 0);
        });

        it('should return an array with 1 item when root has no children', function() {
            assert.lengthOf(flattenSuites(root), 1);
        });

        it('should return an array of n+1 suites for n own children', function() {
            var n = 7;
            _.times(n, _.partial(addChildTo, root));

            assert.lengthOf(flattenSuites(root), n + 1);
        });

        it('should return an array of n+1 suites for n-depth tree', function() {
            var n = 13;
            addGrandNthChild(n, root);

            assert.lengthOf(flattenSuites(root), n + 1);
        });
    });
});
<commit_msg>Migrate suite-util tests to chai.assert<commit_after>'use strict';
var _ = require('lodash'),
    assert = require('chai').assert,

    Browser = require('../lib/browser'),
    suiteUtil = require('../lib/suite-util'),

    shouldSkip = suiteUtil.shouldSkip,
    flattenSuites = suiteUtil.flattenSuites;

describe('suite-util', function() {
    describe('shouldSkip()', function() {
        function makeBrowser(capabilities) {
            var config = {
                browsers: {id: capabilities}
            };
            return new Browser(config, 'id');
        }

        it('should not skip any browser if skipped=false', function() {
            assert.isFalse(shouldSkip(false, makeBrowser({browserName: 'browser'})));
        });

        it('should skip any browser if skipped=true', function() {
            assert.isTrue(shouldSkip(true, makeBrowser({browserName: 'browser'})));
        });

        it('should skip browser if its name and version matches skip list', function() {
            assert.isTrue(shouldSkip(
                [{browserName: 'browser', version: '1.0'}],
                makeBrowser({browserName: 'browser', version: '1.0'})
            ));
        });

        it('should not skip the browser if its name does not match skip list', function() {
            assert.isFalse(shouldSkip(
                [{browserName: 'browser', version: '1.0'}],
                makeBrowser({browserName: 'other browser', version: '1.0'})
            ));
        });

        it('should not skip browser if its version does not match skip list', function() {
            assert.isFalse(shouldSkip(
                [{browserName: 'browser', version: '1.0'}],
                makeBrowser({browserName: 'browser', version: '1.1'})
            ));
        });

        it('should skip any browser of a given name if version is not specified in skip list', function() {
            assert.isTrue(shouldSkip(
                [{browserName: 'browser'}],
                makeBrowser({browserName: 'browser', version: '1.1'})
            ));
        });
    });

    describe('flattenSuites()', function() {
        var root;

        function addChildTo(parent) {
            var child = {};
            parent.children = (parent.children || []).concat(child);
            return child;
        }

        function addGrandNthChild(n, parent) {
            var result = addChildTo;
            while (n-- > 1) {
                result = _.compose(addChildTo, result);
            }
            return result(parent);
        }

        beforeEach(function() {
            root = {name: 'root'};
        });

        it('should return an array when root is falsey', function() {
            assert.isArray(flattenSuites());
        });

        it('should return an empty array when root is falsey', function() {
            assert.lengthOf(flattenSuites(), 0);
        });

        it('should return an array with 1 item when root has no children', function() {
            assert.lengthOf(flattenSuites(root), 1);
        });

        it('should return an array of n+1 suites for n own children', function() {
            var n = 7;
            _.times(n, _.partial(addChildTo, root));

            assert.lengthOf(flattenSuites(root), n + 1);
        });

        it('should return an array of n+1 suites for n-depth tree', function() {
            var n = 13;
            addGrandNthChild(n, root);

            assert.lengthOf(flattenSuites(root), n + 1);
        });
    });
});

{'fraction_non_alphanumeric': 0.13805970149253732, 'fraction_numerical': 0.007175660160734788, 'mean_word_length': 1.9367888748419722, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1272719', 'n_tokens_mistral': 1912, 'n_tokens_neox': 1835, 'n_words': 506}