Bump path-parse from 1.0.6 to 1.0.7
[KisSync.git] / test / configuration / camoconfig.js
blobb676d1cb749739f602819cb148ce506ae11be7b3
1 const assert = require('assert');
2 const CamoConfig = require('../../lib/configuration/camoconfig').CamoConfig;
4 describe('CamoConfig', () => {
5 describe('#constructor', () => {
6 it('strips trailing slashes from the server', () => {
7 const config = new CamoConfig({
8 camo: {
9 server: 'http://abc.xyz/'
11 });
12 assert.strictEqual(config.getServer(), 'http://abc.xyz');
13 });
15 it('defaults to enabled=false', () => {
16 assert.strictEqual(new CamoConfig().isEnabled(), false);
17 });
19 it('validates that encoding must be either url or hex', () => {
21 assert.throws(() => {
22 new CamoConfig({
23 camo: {
24 encoding: 'asdjfnasdf'
26 });
27 }, /must be either 'url' or 'hex'/);
28 });
29 });
31 describe('#getWhitelistedDomains', () => {
32 it('defaults to an empty array', () => {
33 assert.deepStrictEqual(new CamoConfig().getWhitelistedDomains(), []);
34 });
35 });
37 describe('#getEncoding', () => {
38 it('defaults to url', () => {
39 assert.deepStrictEqual(new CamoConfig().getEncoding(), 'url');
40 });
41 });
43 describe('#getWhitelistedDomainsRegexp', () => {
44 it('generates a regex based on the whitelisted domains', () => {
45 const config = new CamoConfig({
46 camo: {
47 server: 'localhost:8081',
48 'whitelisted-domains': ['abc.xyz', 'tii.kzz.qqq']
50 });
52 const re = config.getWhitelistedDomainsRegexp();
53 assert.deepStrictEqual(re, /\.abc\.xyz$|\.tii\.kzz\.qqq$/i);
54 });
55 });
56 });