summaryrefslogtreecommitdiffstats
path: root/lib/modifiers/config/__tests__/togglePlugin.js
blob: 4ac088b768308bc273e0393708e49d3ec6a2e8ea (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
var togglePlugin = require('../togglePlugin');
var Config = require('../../../models/config');
var Book = require('../../../models/book');

describe('togglePlugin', function() {
    var config = Config.createWithValues({
        plugins: ['hello', 'world', '-disabled']
    });
    var book = Book().setConfig(config);

    it('should enable plugin', function() {
        var newBook = togglePlugin(book, 'disabled');
        var newConfig = newBook.getConfig();

        var testDep = newConfig.getPluginDependency('disabled');
        expect(testDep).toBeDefined();
        expect(testDep.getVersion()).toEqual('*');
        expect(testDep.isEnabled()).toBeTruthy();
    });

    it('should disable plugin', function() {
        var newBook = togglePlugin(book, 'world');
        var newConfig = newBook.getConfig();

        var testDep = newConfig.getPluginDependency('world');
        expect(testDep).toBeDefined();
        expect(testDep.getVersion()).toEqual('*');
        expect(testDep.isEnabled()).toBeFalsy();
    });
});