Skip to content
Merged
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
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
},
"version": "19.1.0-next.0",
"dependencies": {
"@angular/animations": "^19.0.0-next.10",
"@angular/common": "^19.0.0-next.10",
"@angular/compiler": "^19.0.0-next.10",
"@angular/core": "^19.0.0-next.10",
"@angular/forms": "^19.0.0-next.10",
"@angular/platform-browser": "^19.0.0-next.10",
"@angular/animations": "^19.0.0-rc.0",
"@angular/common": "^19.0.0-rc.0",
"@angular/compiler": "^19.0.0-rc.0",
"@angular/core": "^19.0.0-rc.0",
"@angular/forms": "^19.0.0-rc.0",
"@angular/platform-browser": "^19.0.0-rc.0",
"@types/google.maps": "^3.54.10",
"@types/youtube": "^0.0.50",
"rxjs": "^6.6.7",
Expand All @@ -70,19 +70,19 @@
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^19.0.0-next.10",
"@angular-devkit/core": "^19.0.0-next.10",
"@angular-devkit/schematics": "^19.0.0-next.10",
"@angular-devkit/build-angular": "^19.0.0-rc.0",
"@angular-devkit/core": "^19.0.0-rc.0",
"@angular-devkit/schematics": "^19.0.0-rc.0",
"@angular/bazel": "https://github.com/angular/bazel-builds.git#d9a8ea4f9e62cb475eff89519426a38631b2704d",
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#74e0e7b090c6e16056290836b2d936ca7820b86f",
"@angular/build": "^19.0.0-next.10",
"@angular/cli": "^19.0.0-next.10",
"@angular/compiler-cli": "^19.0.0-next.10",
"@angular/localize": "^19.0.0-next.10",
"@angular/build": "^19.0.0-rc.0",
"@angular/cli": "^19.0.0-rc.0",
"@angular/compiler-cli": "^19.0.0-rc.0",
"@angular/localize": "^19.0.0-rc.0",
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#36946be4df61f6549ae3829c026022e47674eae2",
"@angular/platform-browser-dynamic": "^19.0.0-next.10",
"@angular/platform-server": "^19.0.0-next.10",
"@angular/router": "^19.0.0-next.10",
"@angular/platform-browser-dynamic": "^19.0.0-rc.0",
"@angular/platform-server": "^19.0.0-rc.0",
"@angular/router": "^19.0.0-rc.0",
"@babel/core": "^7.16.12",
"@babel/helper-explode-assignable-expression": "^7.18.6",
"@babel/helper-string-parser": "^7.22.5",
Expand All @@ -102,7 +102,7 @@
"@octokit/rest": "18.3.5",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@schematics/angular": "^19.0.0-next.10",
"@schematics/angular": "^19.0.0-rc.0",
"@types/babel__core": "^7.1.18",
"@types/browser-sync": "^2.26.3",
"@types/fs-extra": "^9.0.13",
Expand Down
44 changes: 25 additions & 19 deletions src/material/timepicker/timepicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('MatTimepicker', () => {

expect(getPanel()).toBeFalsy();
expect(input.value).toBe('12:30 AM');
expect(fixture.componentInstance.input.value()).toEqual(createTime(0, 30));
expectSameTime(fixture.componentInstance.input.value(), createTime(0, 30));
expect(fixture.componentInstance.selectedSpy).toHaveBeenCalledTimes(1);
expect(fixture.componentInstance.selectedSpy).toHaveBeenCalledWith(
jasmine.objectContaining({
Expand All @@ -91,7 +91,7 @@ describe('MatTimepicker', () => {

// Initial value
expect(fixture.componentInstance.value).toBeTruthy();
expect(inputInstance.value()).toEqual(fixture.componentInstance.value());
expectSameTime(inputInstance.value(), fixture.componentInstance.value());

// Propagation from input back to host
clearElement(input);
Expand All @@ -100,7 +100,7 @@ describe('MatTimepicker', () => {
let value = inputInstance.value()!;
expect(adapter.getHours(value)).toBe(11);
expect(adapter.getMinutes(value)).toBe(15);
expect(fixture.componentInstance.value()).toEqual(value);
expectSameTime(fixture.componentInstance.value(), value);

// Propagation from host down to input
fixture.componentInstance.value.set(createTime(13, 37));
Expand All @@ -109,7 +109,7 @@ describe('MatTimepicker', () => {
value = inputInstance.value()!;
expect(adapter.getHours(value)).toBe(13);
expect(adapter.getMinutes(value)).toBe(37);
expect(value).toEqual(fixture.componentInstance.value());
expectSameTime(fixture.componentInstance.value(), value);
}));

it('should emit the `selected` event if the option being clicked was selected already', fakeAsync(() => {
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('MatTimepicker', () => {

// The user's value shouldn't be overwritten.
expect(input.value).toBe('13:37');
expect(fixture.componentInstance.input.value()).toEqual(createTime(13, 37));
expectSameTime(fixture.componentInstance.input.value(), createTime(13, 37));
});

it('should parse invalid time string', () => {
Expand Down Expand Up @@ -251,14 +251,14 @@ describe('MatTimepicker', () => {
typeInElement(input, '2:10 PM');
fixture.detectChanges();
expect(input.value).toBe('2:10 PM');
expect(inputInstance.value()).toEqual(new Date(...dateParts, 14, 10, 0));
expectSameTime(inputInstance.value(), new Date(...dateParts, 14, 10, 0));
});

it('should not accept an invalid `min` value', () => {
const fixture = TestBed.createComponent(StandaloneTimepicker);
fixture.componentInstance.min.set(createTime(13, 45));
fixture.detectChanges();
expect(fixture.componentInstance.input.min()).toEqual(createTime(13, 45));
expectSameTime(fixture.componentInstance.input.min(), createTime(13, 45));

fixture.componentInstance.min.set(adapter.invalid());
fixture.detectChanges();
Expand All @@ -269,7 +269,7 @@ describe('MatTimepicker', () => {
const fixture = TestBed.createComponent(StandaloneTimepicker);
fixture.componentInstance.max.set(createTime(13, 45));
fixture.detectChanges();
expect(fixture.componentInstance.input.max()).toEqual(createTime(13, 45));
expectSameTime(fixture.componentInstance.input.max(), createTime(13, 45));

fixture.componentInstance.max.set(adapter.invalid());
fixture.detectChanges();
Expand All @@ -280,14 +280,14 @@ describe('MatTimepicker', () => {
const fixture = TestBed.createComponent(StandaloneTimepicker);
fixture.componentInstance.min.set('1:45 PM');
fixture.detectChanges();
expect(fixture.componentInstance.input.min()).toEqual(createTime(13, 45));
expectSameTime(fixture.componentInstance.input.min(), createTime(13, 45));
});

it('should accept a valid time string as the `max`', () => {
const fixture = TestBed.createComponent(StandaloneTimepicker);
fixture.componentInstance.max.set('1:45 PM');
fixture.detectChanges();
expect(fixture.componentInstance.input.max()).toEqual(createTime(13, 45));
expectSameTime(fixture.componentInstance.input.max(), createTime(13, 45));
});

it('should throw if multiple inputs are associated with a timepicker', () => {
Expand Down Expand Up @@ -788,7 +788,7 @@ describe('MatTimepicker', () => {
flush();

expect(input.value).toBe('1:30 AM');
expect(fixture.componentInstance.input.value()).toEqual(createTime(1, 30));
expectSameTime(fixture.componentInstance.input.value(), createTime(1, 30));
expect(getPanel()).toBeFalsy();
expect(event.defaultPrevented).toBeTrue();
expect(fixture.componentInstance.selectedSpy).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -868,7 +868,7 @@ describe('MatTimepicker', () => {

typeInElement(input, '1:37 PM');
fixture.detectChanges();
expect(control.value).toEqual(createTime(13, 37));
expectSameTime(control.value, createTime(13, 37));
expect(control.dirty).toBe(true);
expect(control.touched).toBe(false);

Expand All @@ -890,7 +890,7 @@ describe('MatTimepicker', () => {
getOptions()[5].click();
fixture.detectChanges();

expect(control.value).toEqual(createTime(2, 30));
expectSameTime(control.value, createTime(2, 30));
expect(control.dirty).toBe(true);
});

Expand Down Expand Up @@ -930,7 +930,7 @@ describe('MatTimepicker', () => {
getOptions()[5].click();
fixture.detectChanges();

expect(control.value).toEqual(createTime(2, 30));
expectSameTime(control.value, createTime(2, 30));
expect(control.dirty).toBe(false);
expect(spy).not.toHaveBeenCalled();
subscription.unsubscribe();
Expand All @@ -946,7 +946,7 @@ describe('MatTimepicker', () => {
fixture.componentInstance.input.value.set(createTime(12, 0));
fixture.detectChanges();

expect(control.value).toEqual(createTime(13, 37));
expectSameTime(control.value, createTime(13, 37));
expect(control.dirty).toBe(false);
});

Expand Down Expand Up @@ -1002,7 +1002,7 @@ describe('MatTimepicker', () => {
typeInElement(input, '10:10 AM');
fixture.detectChanges();
expect(control.errors?.['matTimepickerParse']).toBeFalsy();
expect(control.value).toEqual(createTime(10, 10));
expectSameTime(control.value, createTime(10, 10));

clearElement(input);
typeInElement(input, 'not a valid date');
Expand Down Expand Up @@ -1034,7 +1034,7 @@ describe('MatTimepicker', () => {
typeInElement(input, '12:10 PM');
fixture.detectChanges();
expect(control.errors?.['matTimepickerParse']).toBeFalsy();
expect(control.value).toEqual(createTime(12, 10));
expectSameTime(control.value, createTime(12, 10));
}));

it('should set an error if the user enters a time earlier than the minimum', fakeAsync(() => {
Expand All @@ -1052,7 +1052,7 @@ describe('MatTimepicker', () => {
typeInElement(input, '11:59 AM');
fixture.detectChanges();
expect(control.errors?.['matTimepickerMin']).toBeTruthy();
expect(control.value).toEqual(createTime(11, 59));
expectSameTime(control.value, createTime(11, 59));

// Change the minimum so the value becomes valid.
fixture.componentInstance.min.set(createTime(11, 0));
Expand All @@ -1075,7 +1075,7 @@ describe('MatTimepicker', () => {
typeInElement(input, '12:01 PM');
fixture.detectChanges();
expect(control.errors?.['matTimepickerMax']).toBeTruthy();
expect(control.value).toEqual(createTime(12, 1));
expectSameTime(control.value, createTime(12, 1));

// Change the maximum so the value becomes valid.
fixture.componentInstance.max.set(createTime(13, 0));
Expand Down Expand Up @@ -1197,6 +1197,12 @@ describe('MatTimepicker', () => {
});
});

function expectSameTime(one: Date | null, two: Date | null): void {
expect(adapter.sameTime(one, two))
.withContext(`Expected ${one} to be same time as ${two}`)
.toBe(true);
}

function configureTestingModule(additionalProviders: Provider[] = []): void {
TestBed.configureTestingModule({
imports: [NoopAnimationsModule],
Expand Down
Loading
Loading