Created
November 9, 2016 19:51
-
-
Save jherdman/d3b50f67c5771490c41eaaa7fb66bd40 to your computer and use it in GitHub Desktop.
Revisions
-
jherdman created this gist
Nov 9, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ /* 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] } ); }); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ andThen(function() { uploadFile(domSelector, ['fake-file-contents'], { name: 'foo.jpg', type: 'image/jpeg' }); });