Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into APPS-9803_upgrade_w…
Browse files Browse the repository at this point in the history
…dio_to_version_7
  • Loading branch information
refael-m committed Jun 29, 2021
2 parents 681666a + d9ee5f5 commit c26eaf8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@

2.5.0 / 2021-06-28
==================

* feat: add isTimePassed function to TestUtils.ts (#234)
* docs: fix ci badge (#232)
* Bump glob-parent from 5.1.1 to 5.1.2 (#222)
* Bump hosted-git-info from 2.8.8 to 2.8.9 (#223)
* Bump normalize-url from 4.5.0 to 4.5.1 (#224)
* Bump y18n from 3.2.1 to 3.2.2 (#225)
# Changelog

All notable changes to this project will be documented in this file.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wdio-allure-ts",
"version": "2.4.3",
"version": "2.5.0",
"description": "UI E2E testing util",
"license": "MIT",
"author": "Cloudinary <[email protected]>",
Expand Down
12 changes: 12 additions & 0 deletions src/commons/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ export namespace TestUtils {
return str.replace(/[^0-9]/g, '');
}

/**
* Check if number of minutes passed from given time till current time
* @param countDate date to count from
* @param numOfMinutes number of minutes to count
* @private
*/
export function isTimePassed(countDate: Date, numOfMinutes: number): boolean {
const timeInMs = numOfMinutes * 60 * 1000; /* ms */

return new Date().valueOf() - countDate.valueOf() > timeInMs;
}

/**
* Return generic type of data by provided file path
* path File located in wdio config file
Expand Down
11 changes: 11 additions & 0 deletions src/test/specs/TestUtilsSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,15 @@ describe('TestUtilsSpec', () => {
assert.equal(Number(TestUtils.extractNumbersFromString(str)), expectedNumber);
});
});
describe('isTimePassed', () => {
it('expect to return true', () => {
const expectedDate = new Date(2000, 1);
assert.isTrue(TestUtils.isTimePassed(expectedDate, 5));
});

it('expect to return false', () => {
const expectedDate = new Date(3000, 1);
assert.isNotTrue(TestUtils.isTimePassed(expectedDate, 5));
});
});
});

0 comments on commit c26eaf8

Please sign in to comment.