From 90451342a71e682b93b6211873eac4b5e0f2af87 Mon Sep 17 00:00:00 2001
From: Idundun Michael <163633000+Mikitechguy@users.noreply.github.com>
Date: Sat, 6 Apr 2024 07:30:43 +0100
Subject: [PATCH 1/5] added tests files
---
Tests/loader.test.js | 14 ++++
Tests/toolbar.test.js | 33 ++++++++++
Tests/uicallback.test.js | 139 +++++++++++++++++++++++++++++++++++++++
3 files changed, 186 insertions(+)
create mode 100644 Tests/loader.test.js
create mode 100644 Tests/toolbar.test.js
create mode 100644 Tests/uicallback.test.js
diff --git a/Tests/loader.test.js b/Tests/loader.test.js
new file mode 100644
index 000000000..75159beb0
--- /dev/null
+++ b/Tests/loader.test.js
@@ -0,0 +1,14 @@
+const {JSDOM} = require('jsdom');
+
+// test for successful upload
+test('Successful upload', () => {
+ const handleUpload = jest.fn();
+ const mockFile = new File([], 'dummyFile');
+ const mockFilename = 'dummyFilename';
+
+ global.changeStatus = jest.fn();
+
+ return handleUpload(mockFile, mockFilename);
+
+ expect(global.changeStatus).toHaveBeenCalledWith('UPLOAD', 'dummyFile uploaded successfully');
+});
diff --git a/Tests/toolbar.test.js b/Tests/toolbar.test.js
new file mode 100644
index 000000000..6e37219de
--- /dev/null
+++ b/Tests/toolbar.test.js
@@ -0,0 +1,33 @@
+// test for the selected function
+const {JSDOM} = require('jsdom');
+describe('selected function', ()=>{
+ test('should add checked class to all elements until reaching an element with class "multidown"', ()=>{
+ const selected = jest.fn();
+
+ const dom = new JSDOM('
');
+ const element = dom.window.document.querySelector('li');
+ selected(element);
+
+
+ expect(element.classList.contains('checked')).toBe(false);
+ });
+});
+
+
+// test default values
+test('gets default status of form elements', () => {
+ const getStatus = jest.fn().mockReturnValue({
+ select: 'option1',
+ checkbox: false,
+ radio: 'radio1',
+ });
+
+ expect(getStatus({})).toEqual({
+ select: 'option1',
+ checkbox: false,
+ radio: 'radio1',
+ });
+});
+
+
+// test for toggle viewer mode:
diff --git a/Tests/uicallback.test.js b/Tests/uicallback.test.js
new file mode 100644
index 000000000..79c7a2df2
--- /dev/null
+++ b/Tests/uicallback.test.js
@@ -0,0 +1,139 @@
+
+
+// test for toggle viewer mode:
+
+const {JSDOM} = require('jsdom');
+const {toggleSideMenu} = require('../apps/heatmap/uicallbacks');
+
+
+// test for closeSecondary viewer
+describe('closed viewer function', () => {
+ // settting up a basic dom structure using JSDOM
+
+ const dom = new JSDOM(`
+
+
+
+
+
+
+
+ `);
+
+ // global objects for window and document
+
+ global.window = dom.window;
+ global.document = dom.window.document;
+});
+test('closeSecondaryViewer function should update classes and elements correctly', () => {
+ const closeSecondaryViewer = jest.fn();
+
+ const $CAMIC = {
+ viewer: {
+ controls: {
+ bottomright: {style: {display: ''}},
+ },
+ removeHandler: jest.fn(),
+ },
+ };
+
+ const $UI = {
+ lockerPanel: {style: {display: 'block'}},
+ toolbar: {
+ getSubTool: jest.fn(() => ({
+ querySelector: jest.fn(() => ({checked: true})),
+ })),
+ },
+ layersViewerMinor: {
+ toggleAllItems: jest.fn(),
+ setting: {data: [{layer: 'example'}]},
+ },
+ };
+
+ const Loading = {close: jest.fn()};
+
+ // Call the function
+ closeSecondaryViewer();
+
+ // Assertions
+ expect(document.getElementById('main_viewer').classList.contains('main')).toBe(true);
+ expect(document.getElementById('main_viewer').classList.contains('left')).toBe(false);
+ expect(document.getElementById('minor_viewer').classList.contains('none')).toBe(true);
+ expect(document.getElementById('minor_viewer').classList.contains('right')).toBe(false);
+ expect($CAMIC.viewer.controls.bottomright.style.display).toBe('');
+});
+
+
+const $UI = {
+ toolbar: {
+ changeMainToolStatus: jest.fn(),
+ },
+};
+ // testing the toggle side menu function
+describe('toggleSlideMenu', () => {
+ it('should changeMainToolStatus when isOpen is false', () => {
+ const opt = {
+ isOpen: false,
+ target: {id: 'sidebar_menu_1'},
+ };
+
+ const changeMainToolStatusMock = jest.fn();
+ $UI.toolbar.changeMainToolStatus = changeMainToolStatusMock;
+
+ function toggleSideMenu(options) {
+ if (!options.isOpen) {
+ $UI.toolbar.changeMainToolStatus('menu_1', false);
+ }
+ }
+
+ toggleSideMenu(opt);
+
+ expect(changeMainToolStatusMock).toHaveBeenCalledWith('menu_1', false);
+ });
+});
+
+
+// testing for the open secondary viewer
+describe('openSecondaryViewer function', () => {
+ beforeEach(() => {
+ // settting up a basic dom structure using JSDOM
+
+ const dom = new JSDOM(`
+
+
+
+
+
+
+ `);
+
+ // global objects for window and document
+
+ global.window = dom.window;
+ global.document = dom.window.document;
+ });
+
+ afterEach(() => {
+ delete global.window;
+ delete global.document;
+ });
+ test('should update classes and call multSelectorAction after timeout', () => {
+ const openSecondaryViewer = jest.fn();
+ const multSelectorAction = jest.fn();
+ // Mock necessary DOM elements
+
+
+ // Call the function
+ openSecondaryViewer();
+
+
+ // Assertions
+ const main = document.getElementById('main_viewer');
+ const minor = document.getElementById('minor_viewer');
+ expect(minor.classList.contains('none')).toBe(true);
+ expect(minor.classList.contains('right')).toBe(false);
+ // Simulate setTimeout
+ jest.runAllTimers();
+ });
+});
+
From 802aaea878393bd6bce985a96bfc195ba3d0d832 Mon Sep 17 00:00:00 2001
From: Idundun Michael <163633000+Mikitechguy@users.noreply.github.com>
Date: Sat, 6 Apr 2024 07:47:48 +0100
Subject: [PATCH 2/5] Added space between signup button and feedback on hover
---
apps/signup/signup.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/signup/signup.html b/apps/signup/signup.html
index 10243698a..de89023a6 100644
--- a/apps/signup/signup.html
+++ b/apps/signup/signup.html
@@ -52,7 +52,7 @@
-
Signup
-
+    
-
Feedback
From cf8f093603f5c60841772f3e48401fdb72b0b348 Mon Sep 17 00:00:00 2001
From: Michael Idundun <122805291+We13b-MD@users.noreply.github.com>
Date: Sat, 6 Apr 2024 08:01:11 +0100
Subject: [PATCH 3/5] Delete Tests/loader.test.js
---
Tests/loader.test.js | 14 --------------
1 file changed, 14 deletions(-)
delete mode 100644 Tests/loader.test.js
diff --git a/Tests/loader.test.js b/Tests/loader.test.js
deleted file mode 100644
index 75159beb0..000000000
--- a/Tests/loader.test.js
+++ /dev/null
@@ -1,14 +0,0 @@
-const {JSDOM} = require('jsdom');
-
-// test for successful upload
-test('Successful upload', () => {
- const handleUpload = jest.fn();
- const mockFile = new File([], 'dummyFile');
- const mockFilename = 'dummyFilename';
-
- global.changeStatus = jest.fn();
-
- return handleUpload(mockFile, mockFilename);
-
- expect(global.changeStatus).toHaveBeenCalledWith('UPLOAD', 'dummyFile uploaded successfully');
-});
From e3788f8050a29d3293d0f26ecf58257f22cc73fc Mon Sep 17 00:00:00 2001
From: Michael Idundun <122805291+We13b-MD@users.noreply.github.com>
Date: Sat, 6 Apr 2024 08:01:42 +0100
Subject: [PATCH 4/5] Delete Tests/toolbar.test.js
---
Tests/toolbar.test.js | 33 ---------------------------------
1 file changed, 33 deletions(-)
delete mode 100644 Tests/toolbar.test.js
diff --git a/Tests/toolbar.test.js b/Tests/toolbar.test.js
deleted file mode 100644
index 6e37219de..000000000
--- a/Tests/toolbar.test.js
+++ /dev/null
@@ -1,33 +0,0 @@
-// test for the selected function
-const {JSDOM} = require('jsdom');
-describe('selected function', ()=>{
- test('should add checked class to all elements until reaching an element with class "multidown"', ()=>{
- const selected = jest.fn();
-
- const dom = new JSDOM('');
- const element = dom.window.document.querySelector('li');
- selected(element);
-
-
- expect(element.classList.contains('checked')).toBe(false);
- });
-});
-
-
-// test default values
-test('gets default status of form elements', () => {
- const getStatus = jest.fn().mockReturnValue({
- select: 'option1',
- checkbox: false,
- radio: 'radio1',
- });
-
- expect(getStatus({})).toEqual({
- select: 'option1',
- checkbox: false,
- radio: 'radio1',
- });
-});
-
-
-// test for toggle viewer mode:
From 8a46ecd4710f7806ef24f2ab40ad55dfca061b57 Mon Sep 17 00:00:00 2001
From: Michael Idundun <122805291+We13b-MD@users.noreply.github.com>
Date: Sat, 6 Apr 2024 08:02:14 +0100
Subject: [PATCH 5/5] Delete Tests/uicallback.test.js
---
Tests/uicallback.test.js | 139 ---------------------------------------
1 file changed, 139 deletions(-)
delete mode 100644 Tests/uicallback.test.js
diff --git a/Tests/uicallback.test.js b/Tests/uicallback.test.js
deleted file mode 100644
index 79c7a2df2..000000000
--- a/Tests/uicallback.test.js
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-// test for toggle viewer mode:
-
-const {JSDOM} = require('jsdom');
-const {toggleSideMenu} = require('../apps/heatmap/uicallbacks');
-
-
-// test for closeSecondary viewer
-describe('closed viewer function', () => {
- // settting up a basic dom structure using JSDOM
-
- const dom = new JSDOM(`
-
-
-
-
-
-
-
- `);
-
- // global objects for window and document
-
- global.window = dom.window;
- global.document = dom.window.document;
-});
-test('closeSecondaryViewer function should update classes and elements correctly', () => {
- const closeSecondaryViewer = jest.fn();
-
- const $CAMIC = {
- viewer: {
- controls: {
- bottomright: {style: {display: ''}},
- },
- removeHandler: jest.fn(),
- },
- };
-
- const $UI = {
- lockerPanel: {style: {display: 'block'}},
- toolbar: {
- getSubTool: jest.fn(() => ({
- querySelector: jest.fn(() => ({checked: true})),
- })),
- },
- layersViewerMinor: {
- toggleAllItems: jest.fn(),
- setting: {data: [{layer: 'example'}]},
- },
- };
-
- const Loading = {close: jest.fn()};
-
- // Call the function
- closeSecondaryViewer();
-
- // Assertions
- expect(document.getElementById('main_viewer').classList.contains('main')).toBe(true);
- expect(document.getElementById('main_viewer').classList.contains('left')).toBe(false);
- expect(document.getElementById('minor_viewer').classList.contains('none')).toBe(true);
- expect(document.getElementById('minor_viewer').classList.contains('right')).toBe(false);
- expect($CAMIC.viewer.controls.bottomright.style.display).toBe('');
-});
-
-
-const $UI = {
- toolbar: {
- changeMainToolStatus: jest.fn(),
- },
-};
- // testing the toggle side menu function
-describe('toggleSlideMenu', () => {
- it('should changeMainToolStatus when isOpen is false', () => {
- const opt = {
- isOpen: false,
- target: {id: 'sidebar_menu_1'},
- };
-
- const changeMainToolStatusMock = jest.fn();
- $UI.toolbar.changeMainToolStatus = changeMainToolStatusMock;
-
- function toggleSideMenu(options) {
- if (!options.isOpen) {
- $UI.toolbar.changeMainToolStatus('menu_1', false);
- }
- }
-
- toggleSideMenu(opt);
-
- expect(changeMainToolStatusMock).toHaveBeenCalledWith('menu_1', false);
- });
-});
-
-
-// testing for the open secondary viewer
-describe('openSecondaryViewer function', () => {
- beforeEach(() => {
- // settting up a basic dom structure using JSDOM
-
- const dom = new JSDOM(`
-
-
-
-
-
-
- `);
-
- // global objects for window and document
-
- global.window = dom.window;
- global.document = dom.window.document;
- });
-
- afterEach(() => {
- delete global.window;
- delete global.document;
- });
- test('should update classes and call multSelectorAction after timeout', () => {
- const openSecondaryViewer = jest.fn();
- const multSelectorAction = jest.fn();
- // Mock necessary DOM elements
-
-
- // Call the function
- openSecondaryViewer();
-
-
- // Assertions
- const main = document.getElementById('main_viewer');
- const minor = document.getElementById('minor_viewer');
- expect(minor.classList.contains('none')).toBe(true);
- expect(minor.classList.contains('right')).toBe(false);
- // Simulate setTimeout
- jest.runAllTimers();
- });
-});
-