Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
thamara committed Oct 25, 2022
1 parent 07862e7 commit 7a67339
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
1 change: 0 additions & 1 deletion js/main-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ function createWindow()
// Emitted when the window is closed.
mainWindow.on('close', (event) =>
{
app.quit();
const savedPreferences = getUserPreferences();
if (!app.isQuitting && savedPreferences['close-to-tray'])
{
Expand Down
47 changes: 20 additions & 27 deletions tests/main-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,52 +103,45 @@ describe('Application launch', function()
log('Running test - Done');
});

it('Change to Day View', async function()
it('Day View - Current, yesterday and tomorrow', async function()
{
log('Running test ' + this.test.title);
const { client } = this.app;
await client.waitUntilWindowLoaded(10000);

// Switch to Day View
const switchViewBtn = await client.$('#switch-view');
await switchViewBtn.click();
const headerDate = await client.$('#header-date');
const headerDateText = await headerDate.getText();

// Check that changed to current day
let headerDate = await client.$('#header-date');
let 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 pervious Day', async function()
{
log('Running test ' + this.test.title);
const { client } = this.app;
await client.waitUntilWindowLoaded(10000);
const switchViewBtn = await client.$('#switch-view');
await switchViewBtn.click();
// Check that prev day go back to yesterday
const prevDay = await client.$('#prev-day');
prevDay.click();
const headerDate = await client.$('#header-date');
const headerDateText = await headerDate.getText();
const today = new Date();
headerDate = await client.$('#header-date');
headerDateText = await headerDate.getText();
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 ' + this.test.title);
const { client } = this.app;
await client.waitUntilWindowLoaded(10000);
const switchViewBtn = await client.$('#switch-view');
await switchViewBtn.click();
// Back to current day
const currentDay = await client.$('#current-day');
currentDay.click();
headerDate = await client.$('#header-date');
headerDateText = await headerDate.getText();
assert.equal(headerDateText, `${weekDay[today.getDay()]}, ${months[today.getMonth()]} ${today.getDate()}, ${today.getFullYear()}`);

// Check that next day go back to tomorrow
const nextDay = await client.$('#next-day');
nextDay.click();
const headerDate = await client.$('#header-date');
const headerDateText = await headerDate.getText();
const today = new Date();
headerDate = await client.$('#header-date');
headerDateText = await headerDate.getText();
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 7a67339

Please sign in to comment.