Repository navigation
Expand file tree
/
Copy pathuser.plugins.js
More file actions
79 lines (66 loc) · 2.44 KB
/
Copy pathuser.plugins.js
File metadata and controls
79 lines (66 loc) · 2.44 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"use strict";
var browserSync = require("../../../");
var assert = require("chai").assert;
describe("Plugins: Retrieving user plugins", function () {
var PLUGIN_NAME = "KITTENZ";
var instance;
before(function (done) {
browserSync.reset();
var config = {
logLevel: "silent",
open: false
};
browserSync.use({
plugin: function () { /* noop */ },
"plugin:name": PLUGIN_NAME
}, {human: "Shane"});
instance = browserSync(config, done).instance;
});
after(function () {
instance.cleanup();
});
it("Should access to only the user-specified plugins", function (done) {
assert.equal(instance.getUserPlugins().length, 1);
done();
});
it("Should access a single user-specified plugin by name", function (done) {
assert.equal(instance.getUserPlugin(PLUGIN_NAME).name, PLUGIN_NAME);
done();
});
it("Should return false when single user-specified plugin by name is requested, but does not exist", function (done) {
assert.isFalse(instance.getUserPlugin("random-name"));
done();
});
it("Should access to only the user-specified plugins", function (done) {
var plugin = instance.getUserPlugins()[0];
assert.equal(plugin.name, PLUGIN_NAME);
done();
});
it("Disable/re-enable a plugin from event", function (done) {
assert.isTrue(instance.pluginManager.getPlugin(PLUGIN_NAME)._enabled);
instance.events.emit("plugins:configure", {
name: PLUGIN_NAME,
active: false
});
assert.isFalse(instance.options.get("userPlugins")[0].active);
assert.isFalse(instance.pluginManager.getPlugin(PLUGIN_NAME)._enabled);
instance.events.emit("plugins:configure", {
name: PLUGIN_NAME,
active: true
});
assert.isTrue(instance.options.get("userPlugins")[0].active);
assert.isTrue(instance.pluginManager.getPlugin(PLUGIN_NAME)._enabled);
done();
});
it("can set options on user plugins", function () {
var plugin = instance.getUserPlugin(PLUGIN_NAME);
assert.equal(plugin.opts.human, "Shane");
instance.events.emit("plugins:opts", {
name: PLUGIN_NAME,
opts: {
human: "kittie"
}
});
assert.equal(instance.getUserPlugin(PLUGIN_NAME).opts.human, "kittie");
});
});