Skip to content
Merged
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
18 changes: 17 additions & 1 deletion packages/common/src/editors/__tests__/dateEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { Calendar } from 'vanilla-calendar-pro';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { TranslateServiceStub } from '../../../../../test/translateServiceStub.js';
import { SlickEvent, type SlickDataView, type SlickGrid } from '../../core/index.js';
import { FieldType } from '../../enums/index.js';
import type { Column, Editor, EditorArguments, GridOption } from '../../interfaces/index.js';
import { DateEditor } from '../dateEditor.js';
import { Editors } from '../index.js';
Expand Down Expand Up @@ -411,6 +410,23 @@ describe('DateEditor', () => {
expect(editor.isValueTouched()).toBe(true);
});

it('should reset clear-date trigger flag after timeout cycle', () => {
mockItemData = { id: 1, startDate: '2001-01-02T11:02:02.000Z', isActive: true };

editor = new DateEditor(editorArguments);
vi.runAllTimers();

editor.loadValue(mockItemData);
const clearBtnElm = divContainer.querySelector('.btn-clear') as HTMLButtonElement;

clearBtnElm.click();

// Flag is set synchronously by clear() and should reset in timeout callback
expect((editor as any)._lastTriggeredByClearDate).toBe(true);
vi.runOnlyPendingTimers();
expect((editor as any)._lastTriggeredByClearDate).toBe(false);
});

it('should return the first loaded date when date is loaded multiple times then reset', () => {
mockItemData = { id: 1, startDate: '02/25/2020', isActive: true };
mockColumn.type = 'dateUs';
Expand Down
Loading