Fixed errors
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2020-08-18 13:50:08 +02:00
parent 3cfca5690f
commit 540d5e9e71
3 changed files with 32 additions and 1 deletions

View File

@ -19,6 +19,8 @@ class Controller extends Section {
newYear.setFullYear(value);
this.date = newYear;
this.refresh().then(() => this.repaint());
}
get date() {
@ -140,6 +142,9 @@ class Controller extends Section {
if (!this.absenceType)
return this.vnApp.showMessage(this.$t('Choose an absence type from the right menu'));
if (this.year != new Date().getFullYear())
return this.vnApp.showMessage(this.$t('You can just add absences within the current year'));
const day = $days[0];
const stamp = day.getTime();
const event = this.events[stamp];

View File

@ -30,11 +30,14 @@ describe('Worker', () => {
describe('year() setter', () => {
it(`should set the year of the calendar date`, () => {
jest.spyOn(controller, 'refresh').mockReturnValue(new Promise());
const previousYear = year - 1;
controller.year = previousYear;
expect(controller.year).toEqual(previousYear);
expect(controller.date.getFullYear()).toEqual(previousYear);
expect(controller.refresh).toHaveBeenCalledWith();
});
});
@ -157,6 +160,28 @@ describe('Worker', () => {
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Choose an absence type from the right menu');
});
it(`should show an snackbar message if the selected day is not within the current year`, () => {
jest.spyOn(controller.vnApp, 'showMessage').mockReturnThis();
const selectedDay = new Date();
const $event = {
target: {
closest: () => {
return {$ctrl: {}};
}
}
};
const $days = [selectedDay];
const pastYear = new Date();
pastYear.setFullYear(pastYear.getFullYear() - 1);
controller.date = pastYear;
controller.absenceType = {id: 1};
controller.onSelection($event, $days);
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('You can just add absences within the current year');
});
it(`should call to the create() method`, () => {
jest.spyOn(controller, 'create').mockReturnThis();

View File

@ -5,4 +5,5 @@ Year: Año
of: de
days: días
Choose an absence type from the right menu: Elige un tipo de ausencia desde el menú de la derecha
To start adding absences, click an absence type from the right menu and then on the day you want to add an absence: Para empezar a añadir ausencias, haz clic en un tipo de ausencia desde el menu de la derecha y después en el día que quieres añadir la ausencia
To start adding absences, click an absence type from the right menu and then on the day you want to add an absence: Para empezar a añadir ausencias, haz clic en un tipo de ausencia desde el menu de la derecha y después en el día que quieres añadir la ausencia
You can just add absences within the current year: Solo puedes añadir ausencias dentro del año actual