Skip to content
Snippets Groups Projects
Commit adc34000 authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-5756 Reduce click event to <button> tag' (#600) from...

Merge pull request 'OZG-5756 Reduce click event to <button> tag' (#600) from OZG-5756-Klick-weiter-button into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/alfa/pulls/600


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents 7c557005 592ceb3d
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@
import { formatDate, registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';
import {
fixPartialYear,
add2000Years,
formatDateWithoutYearWithTime,
formatForDatabase,
formatFullDate,
......@@ -209,12 +209,12 @@ describe('Date Util', () => {
}
});
describe('fixPartialYear', () => {
describe('add2000Years', () => {
it('should return Date in the 2000 millennium for 2 digit year value', () => {
const dateInput: Date = new Date('0023-10-22');
const yearExpected: number = 2023;
const result: Date = fixPartialYear(dateInput);
const result: Date = add2000Years(dateInput);
expect(result.getFullYear()).toBe(yearExpected);
});
......@@ -222,7 +222,7 @@ describe('Date Util', () => {
it('should return Date unchanged for non 2 digit year value', () => {
const dateInput: Date = new Date('2023-10-22');
const result: Date = fixPartialYear(dateInput);
const result: Date = add2000Years(dateInput);
expect(result).toBe(dateInput);
});
......
......@@ -102,7 +102,8 @@ function convertGermanDateString(dateStr: string): Date {
return new Date(dateStr.replace(/(.*)\.(.*)\.(.*)/, '$3-$2-$1'));
}
export function fixPartialYear(date: Date) {
// Workaround, solange MatDatepicker genutzt wird.
export function add2000Years(date: Date): Date {
const year: number = date.getFullYear();
if (year.toString().length !== 2) {
return date;
......
......@@ -84,14 +84,14 @@ describe('DateEditorComponent', () => {
});
describe('onBlur', () => {
it('should not call fixPartialYear if input value is not Date object', () => {
it('should not call add2000Years if input value is not Date object', () => {
const inputValue: string = '12.12.2024';
component.fieldControl.setValue(inputValue);
const fixPartialYear = jest.spyOn(dateUtil, 'fixPartialYear');
const add2000Years = jest.spyOn(dateUtil, 'add2000Years');
component.onBlur();
expect(fixPartialYear).not.toHaveBeenCalled();
expect(add2000Years).not.toHaveBeenCalled();
});
describe('if input value is Date object', () => {
......@@ -101,12 +101,12 @@ describe('DateEditorComponent', () => {
component.fieldControl.setValue(inputValue);
});
it('should call fixPartialYear', () => {
const fixPartialYear = jest.spyOn(dateUtil, 'fixPartialYear');
it('should call add2000Years', () => {
const add2000Years = jest.spyOn(dateUtil, 'add2000Years');
component.onBlur();
expect(fixPartialYear).toHaveBeenCalledWith(inputValue);
expect(add2000Years).toHaveBeenCalledWith(inputValue);
});
it('should call fieldControl.patchValue', () => {
......
......@@ -21,7 +21,7 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { fixPartialYear } from '@alfa-client/tech-shared';
import { add2000Years } from '@alfa-client/tech-shared';
import { Component, Input } from '@angular/core';
import { MatDatepickerInputEvent } from '@angular/material/datepicker';
import { isDate } from 'date-fns';
......@@ -44,7 +44,7 @@ export class DateEditorComponent extends FormControlEditorAbstractComponent {
return;
}
const value: Date = fixPartialYear(this.fieldControl.value);
const value: Date = add2000Years(this.fieldControl.value);
this.fieldControl.patchValue(value);
this.onChange(value);
......
<ods-button
*ngIf="showButton$ | async"
(click)="clickEmitter.emit($event)"
(clickEmitter)="clickEmitter.emit()"
variant="primary"
size="medium"
class="mt-8 flex"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment