2019-01-02 12:58:55 +03:00
|
|
|
import {triggerEvent} from '@ember/test-helpers';
|
2016-06-11 19:52:36 +03:00
|
|
|
|
2016-05-27 15:27:46 +03:00
|
|
|
export function createFile(content = ['test'], options = {}) {
|
|
|
|
let {
|
|
|
|
name,
|
|
|
|
type
|
|
|
|
} = options;
|
|
|
|
|
|
|
|
let file = new Blob(content, {type: type ? type : 'text/plain'});
|
|
|
|
file.name = name ? name : 'test.txt';
|
|
|
|
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
export function fileUpload(target, content, options) {
|
2016-05-27 15:27:46 +03:00
|
|
|
let file = createFile(content, options);
|
2019-05-13 15:47:52 +03:00
|
|
|
|
2016-05-27 15:27:46 +03:00
|
|
|
return triggerEvent(
|
2019-01-02 12:58:55 +03:00
|
|
|
target,
|
2016-05-27 15:27:46 +03:00
|
|
|
'change',
|
2019-05-13 15:47:52 +03:00
|
|
|
{files: [file]}
|
2016-05-27 15:27:46 +03:00
|
|
|
);
|
2019-01-02 12:58:55 +03:00
|
|
|
}
|