I\'m having difficulties with a unit test in which I want to verify the processing of a file, which would usually be selected in the view via
UPDATE: Thanks to @PeteBD,
Since angularjs version 1.2.22, the jqLite are now support passing a custom event object to triggerHandler()
. See: d262378b
If you are using only jqLite,
the triggerHandler()
will never work as it will pass a dummy event object to handlers.
The dummy event object look like this (copied from jqLite.js#L962)
{
preventDefault: noop,
stopPropagation: noop
}
As you can see, it doesn't even have a target
property.
If you are using jQuery,
you could trigger an event with a custom event object like this:
input.triggerHandler({
type: 'change',
target: {
files: fileList
}
});
and the evt.target.files
will be the fileList
as you are expecting.
Hope this helps.