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({
9 server
: 'http://abc.xyz/'
12 assert
.strictEqual(config
.getServer(), 'http://abc.xyz');
15 it('defaults to enabled=false', () => {
16 assert
.strictEqual(new CamoConfig().isEnabled(), false);
19 it('validates that encoding must be either url or hex', () => {
24 encoding
: 'asdjfnasdf'
27 }, /must be either 'url' or 'hex'/);
31 describe('#getWhitelistedDomains', () => {
32 it('defaults to an empty array', () => {
33 assert
.deepStrictEqual(new CamoConfig().getWhitelistedDomains(), []);
37 describe('#getEncoding', () => {
38 it('defaults to url', () => {
39 assert
.deepStrictEqual(new CamoConfig().getEncoding(), 'url');
43 describe('#getWhitelistedDomainsRegexp', () => {
44 it('generates a regex based on the whitelisted domains', () => {
45 const config
= new CamoConfig({
47 server
: 'localhost:8081',
48 'whitelisted-domains': ['abc.xyz', 'tii.kzz.qqq']
52 const re
= config
.getWhitelistedDomainsRegexp();
53 assert
.deepStrictEqual(re
, /\.abc\.xyz$|\.tii\.kzz\.qqq$/i);