summaryrefslogtreecommitdiffstats
path: root/test/utils/KeyMirror.test.js
diff options
context:
space:
mode:
authorSteven Thomas <steve.thomas@amdocs.com>2018-09-13 16:22:40 -0400
committerSteven Thomas <steve.thomas@amdocs.com>2018-09-13 16:23:05 -0400
commit96319fec0d2af2be5802a56d6b05a3ada939c8df (patch)
tree630e87f62fbbebcded761bf3e67d0f3eb5b78598 /test/utils/KeyMirror.test.js
parentd1975c8134f0401b0ccebf3719eda129d53dac14 (diff)
increasing test coverage to 20 percent
Issue-ID: AAI-1599 Change-Id: I345e38d4319e52b56de0a33d7065e02617cc2103 Signed-off-by: Steven Thomas <steve.thomas@amdocs.com>
Diffstat (limited to 'test/utils/KeyMirror.test.js')
-rw-r--r--test/utils/KeyMirror.test.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/test/utils/KeyMirror.test.js b/test/utils/KeyMirror.test.js
new file mode 100644
index 0000000..22f6ff5
--- /dev/null
+++ b/test/utils/KeyMirror.test.js
@@ -0,0 +1,79 @@
+import keyMirror from 'utils/KeyMirror.js';
+
+describe('KeyMirror', () => {
+ it('valid key mirror with nulls', () => {
+ const obj = {
+ TIER_SUPPORT: null,
+ INVENTORY: null,
+ VNF_SEARCH: null
+ }
+ const mirror = keyMirror(obj);
+
+ for (let key in obj) {
+ expect(mirror).toHaveProperty(key);
+ expect(JSON.stringify(mirror[key])).toBe(JSON.stringify(Symbol(key)));
+ }
+ });
+
+ it('valid key mirror with undefined', () => {
+ const obj = {
+ TIER_SUPPORT: undefined,
+ INVENTORY: undefined,
+ VNF_SEARCH: undefined
+ }
+ const mirror = keyMirror(obj);
+
+ for (let key in obj) {
+ expect(mirror).toHaveProperty(key);
+ expect(JSON.stringify(mirror[key])).toBe(JSON.stringify(Symbol(key)));
+ }
+ });
+
+ it('valid key mirror with values', () => {
+ let preMirrorList = {
+ TIER_SUPPORT: 'tier support',
+ INVENTORY: 'inventory',
+ VNF_SEARCH: 'vnf search'
+ };
+ const mirror = keyMirror(preMirrorList);
+
+ for (let key in preMirrorList) {
+ expect(mirror).toHaveProperty(key);
+ expect(JSON.stringify(mirror[key])).toBe(JSON.stringify(preMirrorList[key]));
+ }
+ });
+
+ it('valid key mirror with objects', () => {
+ let preMirrorList = {
+ TIER_SUPPORT: {
+ name: 'tier support'
+ },
+ INVENTORY: {
+ name: 'inventory'
+ },
+ VNF_SEARCH: {
+ name: 'vnf search'
+ }
+ };
+ const mirror = keyMirror(preMirrorList);
+
+ for (let key in preMirrorList) {
+ expect(mirror).toHaveProperty(key);
+ expect(JSON.stringify(mirror[key])).toBe(JSON.stringify(preMirrorList[key]));
+ }
+ });
+
+ it('invalid key mirror', () => {
+ let preMirrorList = [
+ 'tier support',
+ 'inventory',
+ 'vnf search'
+ ]
+ const mirror = () => {
+ keyMirror(preMirrorList);
+ }
+
+ expect(mirror).toThrow(Error);
+ expect(mirror).toThrowError('keyMirror(...): Argument must be an object.');
+ });
+})