From 4afd9900127f55e949287067afb7201a57bebae4 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Thu, 14 Mar 2024 21:50:05 -0300 Subject: [PATCH 1/2] Migrating workday-waiver-aux.js --- __tests__/__renderer__/workday-waiver-aux.js | 16 +++++++++------- __tests__/electron-mocha-renderer.config.cjs | 2 +- jest.config.js | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/__tests__/__renderer__/workday-waiver-aux.js b/__tests__/__renderer__/workday-waiver-aux.js index 04704706..2be8d11e 100644 --- a/__tests__/__renderer__/workday-waiver-aux.js +++ b/__tests__/__renderer__/workday-waiver-aux.js @@ -1,14 +1,16 @@ /* eslint-disable no-undef */ 'use strict'; -const assert = require('assert'); +import assert from 'assert'; import { formatDayId, displayWaiverWindow } from '../../renderer/workday-waiver-aux.js'; // Mocking call // TODO: find a better way to mock this or even really test it -window.mainApi = { - displayWaiverWindow: () => {} +global.window = { + mainApi: { + displayWaiverWindow: () => {} + } }; describe('Workday Waiver Aux', function() @@ -22,13 +24,13 @@ describe('Workday Waiver Aux', function() describe('formatDayId(dayId)', function() { - test('should be valid', () => + it('should be valid', () => { assert.strictEqual(formatDayId(validJSDay), '2020-04-10'); assert.strictEqual(formatDayId(validJSDay2), '2020-01-10'); }); - test('should not be valid', () => + it('should not be valid', () => { assert.strictEqual(formatDayId(garbageString), NaN); assert.strictEqual(formatDayId(incompleteDate), NaN); @@ -37,7 +39,7 @@ describe('Workday Waiver Aux', function() describe('displayWaiverWindow(dayId)', function() { - test('should do seamless call', async() => + it('should do seamless call', async() => { await displayWaiverWindow(validJSDay); await displayWaiverWindow(validJSDay2); @@ -47,4 +49,4 @@ describe('Workday Waiver Aux', function() }); // TODO: Come up with a way to test displayWaiverWindow's opening of a window -}); \ No newline at end of file +}); diff --git a/__tests__/electron-mocha-renderer.config.cjs b/__tests__/electron-mocha-renderer.config.cjs index 1b703364..1c3bd2c8 100644 --- a/__tests__/electron-mocha-renderer.config.cjs +++ b/__tests__/electron-mocha-renderer.config.cjs @@ -1,5 +1,5 @@ const data = require('./mocha-base.config.cjs'); -data.spec = ['__tests__/__renderer__/themes.js']; +data.spec = ['__tests__/__renderer__/{themes,workday-waiver-aux}.js']; module.exports = data; diff --git a/jest.config.js b/jest.config.js index b3ec69d9..6f7f0105 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,7 +13,7 @@ module.exports = { displayName: 'RENDERER', runner: '@jest-runner/electron', testEnvironment: '@jest-runner/electron/environment', - testMatch: ['**/__tests__/**renderer**/*.js', '**/__tests__/**renderer**/classes/*.js', '!**/themes.js'] + testMatch: ['**/__tests__/**renderer**/*.js', '**/__tests__/**renderer**/classes/*.js', '!**/{themes,workday-waiver-aux}.js'] } ] }; From 4eeda51baadf5b47646b425c9d7a36754ec4d9d3 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Thu, 14 Mar 2024 23:41:54 -0300 Subject: [PATCH 2/2] Migrating notification-channel.js --- __tests__/__renderer__/notification-channel.js | 13 ++++++++----- __tests__/electron-mocha-renderer.config.cjs | 2 +- jest.config.js | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/__tests__/__renderer__/notification-channel.js b/__tests__/__renderer__/notification-channel.js index 6e65fedc..d5c53148 100644 --- a/__tests__/__renderer__/notification-channel.js +++ b/__tests__/__renderer__/notification-channel.js @@ -1,17 +1,20 @@ 'use strict'; -const assert = require('assert'); +import assert from 'assert'; +import jQuery from 'jquery'; +import jsdom from 'jsdom'; -const notificationChannel = require('../../renderer/notification-channel.js'); +import { searchLeaveByElement } from '../../renderer/notification-channel.js'; + +global.$ = jQuery(new jsdom.JSDOM().window); describe('Notifications channel', () => { it('Should get content of #leave-by element', done => { - window.$ = require('jquery'); $('body').append(''); // Way to get the file considered for coverage - notificationChannel.searchLeaveByElement({ + searchLeaveByElement({ sender: { send: (channel, value) => { @@ -22,4 +25,4 @@ describe('Notifications channel', () => } }); }); -}); \ No newline at end of file +}); diff --git a/__tests__/electron-mocha-renderer.config.cjs b/__tests__/electron-mocha-renderer.config.cjs index 1c3bd2c8..f71bc576 100644 --- a/__tests__/electron-mocha-renderer.config.cjs +++ b/__tests__/electron-mocha-renderer.config.cjs @@ -1,5 +1,5 @@ const data = require('./mocha-base.config.cjs'); -data.spec = ['__tests__/__renderer__/{themes,workday-waiver-aux}.js']; +data.spec = ['__tests__/__renderer__/{notification-channel,themes,workday-waiver-aux}.js']; module.exports = data; diff --git a/jest.config.js b/jest.config.js index 6f7f0105..db026a50 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,7 +13,7 @@ module.exports = { displayName: 'RENDERER', runner: '@jest-runner/electron', testEnvironment: '@jest-runner/electron/environment', - testMatch: ['**/__tests__/**renderer**/*.js', '**/__tests__/**renderer**/classes/*.js', '!**/{themes,workday-waiver-aux}.js'] + testMatch: ['**/__tests__/**renderer**/*.js', '**/__tests__/**renderer**/classes/*.js', '!**/{notification-channel,themes,workday-waiver-aux}.js'] } ] };