Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styling adjustment needed in mobile view of table.html page #738 solved #841

Closed
wants to merge 9 commits into from
19 changes: 19 additions & 0 deletions Testfunctions - Copy/loader.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

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");

});

//test for the upload function

41 changes: 41 additions & 0 deletions Testfunctions - Copy/toolbar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

const {JSDOM} = require('jsdom')

//test for the selected function
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('<!DOCTYPE html><html><body><ul><li></li></ul></body></html>');
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'
});
});




184 changes: 184 additions & 0 deletions Testfunctions - Copy/uicallback.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@


// test for toggle viewer mode:

const { JSDOM } = require('jsdom');
const { toggleSideMenu } = require('../apps/heatmap/uicallbacks')

test('calls openSecondaryViewer when checked is true', () => {
const openSecondaryViewer = jest.fn();
const toggleViewerMode = ({ checked }) => {
if (checked) {
openSecondaryViewer();
}
};
toggleViewerMode({ checked: true });
expect(openSecondaryViewer).toHaveBeenCalled();
});




// test for closeSecondary viewer








describe('closed viewer function', () => {

//settting up a basic dom structure using JSDOM

const dom = new JSDOM(`
<html>
<body>
<div id="main_viewer" class="main"></div>
<div id="minor_viewer" class="none"></div>
</body>
</html>

`)

//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(`
<html>
<body>
<div id="main_viewer" class="main"></div>
<div id="minor_viewer" class="none"></div>
</body>
</html>

`)

//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();


});
});







19 changes: 19 additions & 0 deletions Testfunctions/loader.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

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");

});

//test for the upload function

41 changes: 41 additions & 0 deletions Testfunctions/toolbar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

const {JSDOM} = require('jsdom')

//test for the selected function
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('<!DOCTYPE html><html><body><ul><li></li></ul></body></html>');
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'
});
});




Loading