Skip to content

Instantly share code, notes, and snippets.

@jherdman
Created November 9, 2016 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jherdman/d3b50f67c5771490c41eaaa7fb66bd40 to your computer and use it in GitHub Desktop.
Save jherdman/d3b50f67c5771490c41eaaa7fb66bd40 to your computer and use it in GitHub Desktop.
/* global Blob */
// put in tests/helpers
import Ember from 'ember';
const {
Test: {
registerAsyncHelper,
},
} = Ember;
function createFile(content = ['test'], options = {}) {
const {
name,
type
} = options;
const file = new Blob(content, { type : type ? type : 'text/plain' });
file.name = name ? name : 'test.txt';
return file;
}
export default function() {
registerAsyncHelper('uploadFile', function(app, selector, content, options, eventType = 'change') {
const file = createFile(content, options);
return triggerEvent(
selector,
eventType,
{ testingFiles: [file] }
);
});
}
andThen(function() {
uploadFile(domSelector, ['fake-file-contents'], { name: 'foo.jpg', type: 'image/jpeg' });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment