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

Continue electron-mocha-renderer migration #1066

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']
}
]
};
Loading