Skip to content
Open
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
92 changes: 59 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/app/material-timepicker/services/time-adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { DateTime } from 'luxon';


describe('TimeAdapter', () => {
const locale_pl_PL = 'pl-PL';

describe('parseTime', () => {
const locale = 'en-US';


it('should parse from string and return as DateTime', () => {
let expectedHour = 11;
const expectedMinute = 0;
Expand All @@ -29,6 +31,11 @@ describe('TimeAdapter', () => {
expect(TimeAdapter.parseTime('11:00 pm', {locale}).minute).toBe(expectedMinute);
});

it('should parse from string for locale pl-PL and return as DateTime', () => {
expect(TimeAdapter.parseTime('00:10', {locale: locale_pl_PL}).hour).toBe(0);
expect(TimeAdapter.parseTime('00:10', {locale: locale_pl_PL}).minute).toBe(10);
});

it('should parse time from latn to arab number', () => {
const arabLocale = 'ar-AE';
const arabicTime = '١١:١١ ص';
Expand All @@ -54,6 +61,13 @@ describe('TimeAdapter', () => {
expect(TimeAdapter.formatTime('12:20 am', {format})).toBe('12:20 AM');
expect(TimeAdapter.formatTime('12:20 am', {format: 33})).toBe('12:20 AM');
});

it('should convert provided time (en-US) to provided locale (pl-PL) in 24-hours format', () => {
const expected = '0:11';
const actual = '00:11';

expect(TimeAdapter.formatTime(actual, {locale: locale_pl_PL, format: 24})).toBe(expected);
});
});

describe('isTimeAvailable', () => {
Expand Down Expand Up @@ -131,6 +145,7 @@ describe('TimeAdapter', () => {

expect(TimeAdapter.toLocaleTimeString(actual, {locale: 'ar-AE', format: 24})).toBe(expected);
});

});

describe('fromDateTimeToString', () => {
Expand Down
Loading