Skip to content

Commit

Permalink
#918 - Added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sinchananj12 committed Sep 21, 2023
1 parent 80ec883 commit ac7dbb8
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { GoFormErrorsModule } from '../go-form-errors/go-form-errors.module';
describe('GoDatepickerComponent', () => {
let component: GoDatepickerComponent;
let fixture: ComponentFixture<GoDatepickerComponent>;
let inputElement: HTMLInputElement;

beforeEach(async(() => {
TestBed.configureTestingModule({
Expand Down Expand Up @@ -41,6 +42,7 @@ describe('GoDatepickerComponent', () => {
fixture = TestBed.createComponent(GoDatepickerComponent);
component = fixture.componentInstance;
component.control = new FormControl('');
inputElement = fixture.nativeElement.querySelector("input");
});

it('should create', () => {
Expand Down Expand Up @@ -246,4 +248,22 @@ describe('GoDatepickerComponent', () => {
});
});

describe("onInputCloseCalendar", () => {
it("close the calendar when the user interacts with the date field by typing inside it. ", () => {
component.goCalendar.openCalendar(new Date());

component.onInputCloseCalendar();

expect(component.goCalendar.isOpen).toBe(false);
});

it("should call onInputCloseCalendar() when input event is emitted.", () => {
const onInputCloseCalendarSpy = spyOn(component, "onInputCloseCalendar");

inputElement.dispatchEvent(new Event("input"));

expect(onInputCloseCalendarSpy).toHaveBeenCalled();
});
});

});

0 comments on commit ac7dbb8

Please sign in to comment.