Skip to content
Snippets Groups Projects
Commit 9be5d5dc authored by Piotr Gawron's avatar Piotr Gawron
Browse files

stringToBlob method extracted

parent 32cfc968
No related branches found
No related tags found
1 merge request!904Resolve "TYPE Genetic variant does not change on generic during data overlay upload"
"use strict";
var Readable = require('stream').Readable;
var toBlob = require('stream-to-blob');
require("../mocha-config");
var $ = require('jquery');
......@@ -64,7 +61,6 @@ describe('AddOverlayDialog', function () {
describe('processFile', function () {
it('set default type', function () {
var dialog;
var file;
return ServerConnector.getProject().then(function (project) {
dialog = createDialog(project);
return dialog.init();
......@@ -73,19 +69,8 @@ describe('AddOverlayDialog', function () {
dialog.setType("GENETIC_VARIANT");
assert.equal("GENETIC_VARIANT", dialog.getType());
var stream = new Readable;
stream.push("s1\n");
stream.push(null);
return new Promise(function (resolve, reject) {
toBlob(stream, function (err, blob) {
if (err) return reject(err.message);
file = blob;
file.name = "test.txt";
resolve(blob);
})
});
}).then(function () {
return helper.stringToBlob("s1\n");
}).then(function (file) {
return dialog.processFile(file);
}).then(function () {
assert.equal("GENERIC", dialog.getType());
......
"use strict";
var Readable = require('stream').Readable;
var toBlob = require('stream-to-blob');
require("./mocha-config");
var $ = require('jquery');
......@@ -643,6 +646,25 @@ Helper.prototype.createGoogleCanvas = function () {
});
};
/**
*
* @param {string} content
* @return {Promise<Blob>}
*/
Helper.prototype.stringToBlob = function (content) {
var stream = new Readable;
stream.push(content);
stream.push(null);
return new Promise(function (resolve, reject) {
toBlob(stream, function (err, blob) {
if (err) return reject(err.message);
blob.name = "test.txt";
resolve(blob);
})
});
};
/**
*
* @type {number}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment