Test that event handler is called when file input receives data Test that event handler is called when file input receives data angular angular

Test that event handler is called when file input receives data


Is there another way to manually assign the value of the input field

You can't assign value to input[type="file"] due to security reasons.

or at least get it to send an event that is handled by fileChange

You can fire change event after spyOn:

spyOn(component, 'fileChange');input.dispatchEvent(new Event('change'));expect(component.fileChange).toHaveBeenCalled();

Plunker Example


describe("A suite is just a function", function() {  var a;  it("and so is a spec", function() {    a = true;    expect(a).toBe(true);  });});