Skip to content

Commit

Permalink
Adding debug messages to mocha tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thamara committed Oct 17, 2022
1 parent faeda51 commit 08ea941
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions tests/main-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,64 @@ process.env.NODE_ENV = 'test';
const months = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ];
const weekDay = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ];

function log(msg)
{
console.log(`${(new Date()).toISOString().substr(0, 19)}: ${msg}`);
}

describe('Application launch', function()
{
this.timeout(20000);
this.timeout(10000);
beforeEach(async function()
{
this.app = new Application({
path: electronPath,
args: [path.join(__dirname, '..')],
waitTimeout: 10000
waitTimeout: 10000,
quitTimeout: 200
});
log('Start app...')
await this.app.start();
log('App started.')
});

afterEach(async function()
{
log(`App is running: ${this.app && this.app.isRunning()}`)
if (this.app && this.app.isRunning())
{
log('Stop app...');
await this.app.stop();
log('App stoped');
}
});

it('App opens correctly', async function()
{
log('Running test');
const { client, browserWindow } = this.app;
await client.waitUntilWindowLoaded();
const title = await browserWindow.getTitle();
assert.equal(title, 'Time to Leave');
log('Running test - Done');
});

it('Calendar opens on Current Month/Year', async function()
{
log('Running test');
const { client } = this.app;
await client.waitUntilWindowLoaded();

const monthYear = await client.$('#month-year');
const monthYearText = await monthYear.getText();
const today = new Date();
assert.equal(monthYearText, `${months[today.getMonth()]} ${today.getFullYear()}`);
log('Running test - Done');
});

it('Change to Day View', async function()
{
log('Running test');
const { client } = this.app;
await client.waitUntilWindowLoaded();

Expand All @@ -61,10 +77,12 @@ describe('Application launch', function()
const headerDateText = await headerDate.getText();
const today = new Date();
assert.equal(headerDateText, `${weekDay[today.getDay()]}, ${months[today.getMonth()]} ${today.getDate()}, ${today.getFullYear()}`);
log('Running test - Done');
});

it('Calendar change to previous Month', async function()
{
log('Running test');
const { client } = this.app;
await client.waitUntilWindowLoaded();

Expand All @@ -75,10 +93,12 @@ describe('Application launch', function()
const today = new Date();
const prevMonthDate = new Date(today.getFullYear(), today.getMonth(), -1);
assert.equal(monthYearText, `${months[prevMonthDate.getMonth()]} ${prevMonthDate.getFullYear()}`);
log('Running test - Done');
});

it('Calendar change to next Month', async function()
{
log('Running test');
const { client } = this.app;
await client.waitUntilWindowLoaded();

Expand All @@ -89,10 +109,12 @@ describe('Application launch', function()
const today = new Date();
const nextMonthDate = new Date(today.getFullYear(), today.getMonth() + 1, 1);
assert.equal(monthYearText, `${months[nextMonthDate.getMonth()]} ${nextMonthDate.getFullYear()}`);
log('Running test - Done');
});

it('Calendar change to pervious Day', async function()
{
log('Running test');
const { client } = this.app;
await client.waitUntilWindowLoaded();
const switchViewBtn = await client.$('#switch-view');
Expand All @@ -104,10 +126,12 @@ describe('Application launch', function()
const today = new Date();
const previousDayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1);
assert.equal(headerDateText, `${weekDay[previousDayDate.getDay()]}, ${months[previousDayDate.getMonth()]} ${previousDayDate.getDate()}, ${previousDayDate.getFullYear()}`);
log('Running test - Done');
});

it('Calendar change to next Day', async function()
{
log('Running test');
const { client } = this.app;
await client.waitUntilWindowLoaded();
const switchViewBtn = await client.$('#switch-view');
Expand All @@ -119,5 +143,6 @@ describe('Application launch', function()
const today = new Date();
const nextDayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1);
assert.equal(headerDateText, `${weekDay[nextDayDate.getDay()]}, ${months[nextDayDate.getMonth()]} ${nextDayDate.getDate()}, ${nextDayDate.getFullYear()}`);
log('Running test - Done');
});
});

0 comments on commit 08ea941

Please sign in to comment.