Skip to content

Commit

Permalink
Merge pull request #1066 from araujoarthur0/continue-electron-mocha-r…
Browse files Browse the repository at this point in the history
…enderer-migration
  • Loading branch information
tupaschoal authored Mar 16, 2024
2 parents 23f0560 + 4eeda51 commit d1da985
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
13 changes: 8 additions & 5 deletions __tests__/__renderer__/notification-channel.js
Original file line number Diff line number Diff line change
@@ -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('<input id="leave-by" value="12:12" />');
// Way to get the file considered for coverage
notificationChannel.searchLeaveByElement({
searchLeaveByElement({
sender: {
send: (channel, value) =>
{
Expand All @@ -22,4 +25,4 @@ describe('Notifications channel', () =>
}
});
});
});
});
16 changes: 9 additions & 7 deletions __tests__/__renderer__/workday-waiver-aux.js
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -47,4 +49,4 @@ describe('Workday Waiver Aux', function()
});

// TODO: Come up with a way to test displayWaiverWindow's opening of a window
});
});
2 changes: 1 addition & 1 deletion __tests__/electron-mocha-renderer.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const data = require('./mocha-base.config.cjs');

data.spec = ['__tests__/__renderer__/themes.js'];
data.spec = ['__tests__/__renderer__/{notification-channel,themes,workday-waiver-aux}.js'];

module.exports = data;
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', '!**/{notification-channel,themes,workday-waiver-aux}.js']
}
]
};

0 comments on commit d1da985

Please sign in to comment.