Created
November 9, 2016 19:51
-
-
Save jherdman/d3b50f67c5771490c41eaaa7fb66bd40 to your computer and use it in GitHub Desktop.
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 characters
/* 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 characters
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