1 | var yaml = require('js-yaml');
|
2 |
|
3 | var configKeys = ['application', 'authentication', 'features', 'server', 'authorization', 'pages', 'customizations'];
|
4 | var Config = require("../../lib/config");
|
5 |
|
6 | describe ("Config", function() {
|
7 |
|
8 | Config.setup();
|
9 |
|
10 | afterEach(function() {
|
11 |
|
12 | Config.setup();
|
13 | });
|
14 |
|
15 | it ("should render a valid config in YAML", function() {
|
16 |
|
17 | var def = yaml.load(Config.sample());
|
18 |
|
19 | expect(Object.keys(def).join('')).to.equal(configKeys.join(''));
|
20 |
|
21 | expect(def.application.title).to.equal('Jingo');
|
22 | expect(def.application.repository).to.equal('');
|
23 | expect(def.application.docSubdir).to.equal('');
|
24 | expect(def.application.remote).to.equal('');
|
25 | expect(def.application.pushInterval).to.equal(30);
|
26 | expect(def.application.secret).to.equal('change me');
|
27 |
|
28 | expect(def.features.codemirror).to.be.true;
|
29 | expect(def.features.markitup).to.be.false;
|
30 |
|
31 | expect(def.server.hostname).to.equal('localhost');
|
32 | expect(def.server.port).to.equal(6067);
|
33 | expect(def.server.localOnly).to.be.false;
|
34 |
|
35 | expect(def.authorization.anonRead).to.be.true;
|
36 | expect(def.authorization.validMatches).to.equal('.+');
|
37 | expect(def.authorization.emptyEmailMatches).to.be.false;
|
38 |
|
39 | expect(def.authentication.google.enabled).to.be.true;
|
40 | expect(def.authentication.local.enabled).to.be.false;
|
41 | });
|
42 |
|
43 | it ("should get the config as a whole", function() {
|
44 |
|
45 | var c;
|
46 | try {
|
47 | var c = Config.get();
|
48 | } catch(e) {
|
49 | c = 'boom';
|
50 | }
|
51 |
|
52 | expect(c).to.equal('boom');
|
53 |
|
54 | Config.setup({
|
55 | test: 23
|
56 | });
|
57 |
|
58 | expect(Config.get()).to.be.an("object");
|
59 | });
|
60 |
|
61 | it ("should get a variable from the config", function() {
|
62 |
|
63 | Config.setup({
|
64 | test: 23,
|
65 | test1: {
|
66 | test2: 44
|
67 | }
|
68 | });
|
69 |
|
70 | expect(Config.get("test")).to.equal(23);
|
71 | expect(Config.get("test1").test2).to.equal(44);
|
72 | });
|
73 |
|
74 | }); |
\ | No newline at end of file |