<commit_before>var PluginDependency = require('../../models/pluginDependency');
var sortPlugins = require('../sortPlugins');
var listAll = require('../listAll');

describe('sortPlugins', function() {
    it('must load themes after plugins', function() {
        var deps = PluginDependency.listFromString('theme-faq'),
            allPlugins = listAll(deps);

        var sorted = sortPlugins(allPlugins, []);

        var plugins = sorted.slice(0, -2),
            themes = sorted.slice(-2);

        var pluginsOk = plugins.every(function(plugin) {
            return !plugin.isTheme();
        });

        var themesOk = themes.every(function(theme) {
            return theme.isTheme();
        });

        expect(pluginsOk).toBe(true);
        expect(plugins.has('search')).toBe(true);

        expect(themesOk).toBe(true);
        expect(themes.size).toBe(2);
        expect(themes.has('theme-faq')).toBe(true);
        expect(themes.has('theme-default')).toBe(true);

        // theme-default should be last
        expect(themes.last().getName()).toBe('theme-default');
    });

    it('must load themes after plugins with a complex dependencies list', function() {
        var deps = PluginDependency.listFromString('comment,theme-faq,-search,ga'),
            allPlugins = listAll(deps);

        var sorted = sortPlugins(allPlugins, []);

        var plugins = sorted.slice(0, -2),
            themes = sorted.slice(-2);

        var pluginsOk = plugins.every(function(plugin) {
            return !plugin.isTheme();
        });

        var themesOk = themes.every(function(theme) {
            return theme.isTheme();
        });

        expect(pluginsOk).toBe(true);
        expect(plugins.has('search')).toBe(false);

        expect(themesOk).toBe(true);
        expect(themes.size).toBe(2);
        expect(themes.has('theme-faq')).toBe(true);
        expect(themes.has('theme-default')).toBe(true);
    });
});<commit_msg>Compare list of plugins sorted to array of names in tests<commit_after>var PluginDependency = require('../../models/pluginDependency');
var sortPlugins = require('../sortPlugins');
var listAll = require('../listAll');

describe('sortPlugins', function() {
    it('must load themes after plugins', function() {
        var deps = PluginDependency.listFromString('theme-faq'),
            allPlugins = listAll(deps);

        var sorted = sortPlugins(allPlugins, []);
        var names = sorted
            .map(function(plugin) {
                return plugin.getName();
            })
            .toArray();

        expect(names).toEqual([
            'fontsettings',
            'sharing',
            'lunr',
            'search',
            'highlight',
            'theme-faq',
            'theme-default'
        ]);
    });

    it('must load themes after plugins with a complex dependencies list', function() {
        var deps = PluginDependency.listFromString('comment,theme-faq,-search,ga'),
            allPlugins = listAll(deps);

        var sorted = sortPlugins(allPlugins, []);
        var names = sorted
            .map(function(plugin) {
                return plugin.getName();
            })
            .toArray();

        expect(names).toEqual([
            'ga',
            'comment',
            'fontsettings',
            'sharing',
            'lunr',
            'highlight',
            'theme-faq',
            'theme-default'
        ]);
    });
});
{'fraction_non_alphanumeric': 0.14973730297723292, 'fraction_numerical': 0.002335084646818447, 'mean_word_length': 2.1382783882783882, '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': '3087768', 'n_tokens_mistral': 951, 'n_tokens_neox': 918, 'n_words': 178}