Skip to content

Commit

Permalink
🐛 fix the breaking JS unit test file
Browse files Browse the repository at this point in the history
Signed-off-by: Najam Ul Saqib <[email protected]>
  • Loading branch information
njmulsqb committed Sep 26, 2023
1 parent 7efc5cc commit da63d0e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
37 changes: 36 additions & 1 deletion src/main/zapHomeFiles/hud/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,40 @@ const utils = (function () {
const dateObject = new Date(Number(timestamp));
return dateObject.toISOString().slice(11, 23);
}

module.exports= {
parseRequestHeader,
parseResponseHeader,
isFromTrustedOrigin,
parseDomainFromUrl,
getParameter,
isHUDInitialized,
initializeHUD,
loadFrame,
saveFrame,
registerTool,
registerTools,
loadTool,
writeTool,
loadPanelTools,
loadAllTools,
addToolToPanel,
removeToolFromPanel,
messageFrame,
messageAllTabs,
getAllClients,
getWindowVisibilityState,
messageWindow,
sortToolsByPosition,
configureButtonHtml,
getUpgradedDomain,
getUpgradedUrl,
errorHandler,
getZapFilePath,
getZapImagePath,
zapApiErrorDialog,
log,
timestampToTimeString
};
return {
parseRequestHeader,
parseResponseHeader,
Expand Down Expand Up @@ -768,4 +801,6 @@ const utils = (function () {
log,
timestampToTimeString
};


})();
10 changes: 5 additions & 5 deletions src/test/js/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const test = require('ava');
const utils = require('../../../src/main/zapHomeFiles/hud/utils.js');

// TODO: use clean build system
// Dynamically load utils functions from utils.js
// <dirty-hack>
const fs = require('fs');
// const fs = require('fs');

const CODE_PATH = './src/main/zapHomeFiles/hud/utils.js';
const jsCode = fs.readFileSync(CODE_PATH, 'utf-8');
global.eval(jsCode);
// const CODE_PATH = './src/main/zapHomeFiles/hud/utils.js';
// const jsCode = fs.readFileSync(CODE_PATH, 'utf-8');
// global.eval(jsCode);
// </dirty-hack>

test('sortToolsByPosition result are in descending order', t => {
const tools = [{
position: 3,
Expand Down

0 comments on commit da63d0e

Please sign in to comment.