cibernox / ember-native-dom-helpers

Test helpers for your integration tests that fire native events
MIT License
186 stars 37 forks source link

Options object not included in the event object for the change event for file selector. #146

Open simpleclicks opened 6 years ago

simpleclicks commented 6 years ago

When I send in the options through the trigger event for the 'change' event on the file input selector, buildFileEvent gets called and the function does not include the options with the event object returned.

function buildFileEvent(type, element, files = []) {
  let event = buildBasicEvent(type);

  if (files.length > 0) {
    Object.defineProperty(files, 'item', {
      value(index) {
        return typeof index === 'number' ? this[index] : null;
      }
    });
    Object.defineProperty(element, 'files', {
      value: files
    });
  }

  Object.defineProperty(event, 'target', {
    value: element
  });

  return event;
}
cibernox commented 6 years ago

If you are able to, I'd recommend stop using the triggerEvent from this addon and instead use the one in @ember/test-helpers (note: It required ember-cli-qunit 4.3 or greater). The helpers in this addon have been copied there and perfected, so this one will soon be deprecated.