summaryrefslogtreecommitdiffstats
path: root/lib/plugins/__tests__/sortDependencies.js
blob: 87df477f542f4dbbd0aeb89fefe887961d7a79df (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
var PluginDependency = require('../../models/pluginDependency');
var sortDependencies = require('../sortDependencies');
var toNames = require('../toNames');

describe('sortDependencies', function() {
    it('must load themes after plugins', function() {
        var allPlugins = PluginDependency.listFromArray([
            'hello',
            'theme-test',
            'world'
        ]);

        var sorted = sortDependencies(allPlugins);
        var names = toNames(sorted);

        expect(names).toEqual([
            'hello',
            'world',
            'theme-test'
        ]);
    });

    it('must keep order of themes', function() {
        var allPlugins = PluginDependency.listFromArray([
            'theme-test',
            'theme-test1',
            'hello',
            'theme-test2',
            'world'
        ]);
        var sorted = sortDependencies(allPlugins);
        var names = toNames(sorted);

        expect(names).toEqual([
            'hello',
            'world',
            'theme-test',
            'theme-test1',
            'theme-test2'
        ]);
    });
});