summaryrefslogtreecommitdiffstats
path: root/lib/plugins/__tests__/sortPlugins.js
blob: c50c851584f2d03cfbc6337eaace34161e0432e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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'
        ]);
    });
});