generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
61 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
import {isInDowntime} from '../src/check' | ||
import {isInDowntime, getUTCAdjustments} from '../src/check' | ||
|
||
describe('isInDowntime should', () => { | ||
const currentDate = new Date(Date.UTC(2021, 1, 13, 12, 53)) | ||
const tz = 3.5 | ||
const utcAdjustments = getUTCAdjustments(3.5) | ||
|
||
test('return false when no downtime is provided', () => { | ||
expect(isInDowntime(currentDate, tz)).toBe(false) | ||
expect(isInDowntime(currentDate, utcAdjustments)).toBe(false) | ||
}) | ||
|
||
test('throw error when downtime does not match pattern', () => { | ||
expect(() => isInDowntime(currentDate, tz, '6:00-7:00')).toThrow( | ||
'Invalid downtime' | ||
) | ||
expect(() => | ||
isInDowntime(currentDate, utcAdjustments, '6:00-7:00') | ||
).toThrow('Invalid downtime') | ||
}) | ||
|
||
test('throw error when downtime is not valid time', () => { | ||
expect(() => isInDowntime(currentDate, tz, '17:00-24:00')).toThrow( | ||
'Invalid downtime' | ||
) | ||
expect(() => | ||
isInDowntime(currentDate, utcAdjustments, '17:00-24:00') | ||
).toThrow('Invalid downtime') | ||
}) | ||
|
||
test('throw error when downtime start time is after end time', () => { | ||
expect(() => isInDowntime(currentDate, tz, '16:30-07:00')).toThrow( | ||
'Invalid downtime' | ||
) | ||
expect(() => | ||
isInDowntime(currentDate, utcAdjustments, '16:30-07:00') | ||
).toThrow('Invalid downtime') | ||
}) | ||
|
||
test('return true when in downtime', () => { | ||
expect(isInDowntime(currentDate, tz, '16:00-23:59')).toBe(true) | ||
expect(isInDowntime(currentDate, utcAdjustments, '16:00-23:59')).toBe(true) | ||
}) | ||
|
||
test('return false when not in downtime', () => { | ||
expect(isInDowntime(currentDate, tz, '16:30-23:59')).toBe(false) | ||
expect(isInDowntime(currentDate, utcAdjustments, '16:30-23:59')).toBe(false) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters