-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98228c5
commit 4025a73
Showing
1 changed file
with
169 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,17 +138,17 @@ test_toArray.parameters = { | |
str: "[email protected]\n#[email protected]\[email protected]", | ||
expected: ["[email protected]", "[email protected]"], | ||
}, | ||
"null to null": { | ||
"null to empty": { | ||
str: null, | ||
expected: null, | ||
expected: [], | ||
}, | ||
"undefined to null": { | ||
"undefined to empty": { | ||
str: undefined, | ||
expected: null, | ||
expected: [], | ||
}, | ||
"empty string to null": { | ||
"empty string to empty": { | ||
str: "", | ||
expected: null, | ||
expected: [], | ||
}, | ||
} | ||
export function test_toArray({ str, expected }) { | ||
|
@@ -251,20 +251,178 @@ test_toDictionaryCommon.parameters = { | |
}, | ||
"null to null": { | ||
str: null, | ||
expected: null, | ||
expected: {}, | ||
}, | ||
"undefined to null": { | ||
"undefined to empty": { | ||
str: undefined, | ||
expected: null, | ||
expected: {}, | ||
}, | ||
"empty string to null": { | ||
"empty string to empty": { | ||
str: "", | ||
expected: null, | ||
expected: {}, | ||
}, | ||
} | ||
export function test_toDictionaryCommon({ str, expected }) { | ||
is( | ||
expected, | ||
ConfigLoader.toDictionary(str, ConfigLoader.commonParamDefs) | ||
); | ||
} | ||
|
||
export function test_createDefaultConfig() { | ||
is( | ||
{ | ||
common: { | ||
CountEnabled: true, | ||
CountAllowSkip: true, | ||
SafeBccEnabled: true, | ||
MainSkipIfNoExt: false, | ||
SafeNewDomainsEnabled: true, | ||
CountSeconds: 3, | ||
SafeBccThreshold: 4, | ||
}, | ||
trustedDomains: [], | ||
unsafeDomains: [], | ||
unsafeFiles: [], | ||
}, | ||
ConfigLoader.createDefaultConfig() | ||
); | ||
} | ||
|
||
export function test_createEmptyConfig() { | ||
is( | ||
{ | ||
common: {}, | ||
trustedDomains: [], | ||
unsafeDomains: [], | ||
unsafeFiles: [], | ||
}, | ||
ConfigLoader.createEmptyConfig() | ||
); | ||
} | ||
|
||
|
||
test_merge.parameters = { | ||
"left is empty": { | ||
left: { | ||
common: {}, | ||
trustedDomains: [], | ||
unsafeDomains: [], | ||
unsafeFiles: [], | ||
}, | ||
right: { | ||
common: { | ||
CountEnabled: true, | ||
CountAllowSkip: true, | ||
SafeBccEnabled: true, | ||
MainSkipIfNoExt: true, | ||
SafeNewDomainsEnabled: true, | ||
CountSeconds: 3, | ||
SafeBccThreshold: 4, | ||
}, | ||
trustedDomains: ["trustedDomain"], | ||
unsafeDomains: ["unsafeDomain"], | ||
unsafeFiles: ["unsafeFile"], | ||
}, | ||
expected: { | ||
common: { | ||
CountEnabled: true, | ||
CountAllowSkip: true, | ||
SafeBccEnabled: true, | ||
MainSkipIfNoExt: true, | ||
SafeNewDomainsEnabled: true, | ||
CountSeconds: 3, | ||
SafeBccThreshold: 4, | ||
}, | ||
trustedDomains: ["trustedDomain"], | ||
unsafeDomains: ["unsafeDomain"], | ||
unsafeFiles: ["unsafeFile"], | ||
} | ||
}, | ||
"right is empty": { | ||
left: { | ||
common: { | ||
CountEnabled: true, | ||
CountAllowSkip: true, | ||
SafeBccEnabled: true, | ||
MainSkipIfNoExt: true, | ||
SafeNewDomainsEnabled: true, | ||
CountSeconds: 3, | ||
SafeBccThreshold: 4, | ||
}, | ||
trustedDomains: ["trustedDomain"], | ||
unsafeDomains: ["unsafeDomain"], | ||
unsafeFiles: ["unsafeFile"], | ||
}, | ||
right: { | ||
common: {}, | ||
trustedDomains: [], | ||
unsafeDomains: [], | ||
unsafeFiles: [], | ||
}, | ||
expected: { | ||
common: { | ||
CountEnabled: true, | ||
CountAllowSkip: true, | ||
SafeBccEnabled: true, | ||
MainSkipIfNoExt: true, | ||
SafeNewDomainsEnabled: true, | ||
CountSeconds: 3, | ||
SafeBccThreshold: 4, | ||
}, | ||
trustedDomains: ["trustedDomain"], | ||
unsafeDomains: ["unsafeDomain"], | ||
unsafeFiles: ["unsafeFile"], | ||
} | ||
}, | ||
"use right defined params": { | ||
left: { | ||
common: { | ||
CountEnabled: true, | ||
CountAllowSkip: true, | ||
SafeBccEnabled: true, | ||
MainSkipIfNoExt: true, | ||
SafeNewDomainsEnabled: true, | ||
CountSeconds: 3, | ||
SafeBccThreshold: 4, | ||
}, | ||
trustedDomains: ["trustedDomain_left"], | ||
unsafeDomains: ["unsafeDomain_left"], | ||
unsafeFiles: ["unsafeFile_left"], | ||
}, | ||
right: { | ||
common: { | ||
CountEnabled: false, | ||
CountAllowSkip: false, | ||
SafeBccEnabled: false, | ||
MainSkipIfNoExt: false, | ||
SafeNewDomainsEnabled: false, | ||
CountSeconds: 2, | ||
SafeBccThreshold: 2, | ||
}, | ||
trustedDomains: ["trustedDomain_right"], | ||
unsafeDomains: ["unsafeDomain_right"], | ||
unsafeFiles: ["unsafeFile_right"], | ||
}, | ||
expected: { | ||
common: { | ||
CountEnabled: false, | ||
CountAllowSkip: false, | ||
SafeBccEnabled: false, | ||
MainSkipIfNoExt: false, | ||
SafeNewDomainsEnabled: false, | ||
CountSeconds: 2, | ||
SafeBccThreshold: 2, | ||
}, | ||
trustedDomains: ["trustedDomain_left", "trustedDomain_right"], | ||
unsafeDomains: ["unsafeDomain_left", "unsafeDomain_right"], | ||
unsafeFiles: ["unsafeFile_left", "unsafeFile_right"], | ||
}, | ||
}, | ||
} | ||
export function test_merge({ left, right, expected }) { | ||
is( | ||
expected, | ||
ConfigLoader.merge(left, right) | ||
); | ||
} |