Fix mock server to fix specs.

This commit is contained in:
nobuti 2017-08-29 15:03:44 +02:00
parent 8fd20a0f35
commit c2232a6d01
2 changed files with 294 additions and 293 deletions

View File

@ -1,5 +1,8 @@
!function(){ var $ = require('jquery');
'use strict'; var Backbone = require('backbone');
var _ = require('underscore');
require('../backbone-model-file-upload');
var Blob = require('blob');
describe('Testing Backbone Model Plugin', function () { describe('Testing Backbone Model Plugin', function () {
@ -293,5 +296,3 @@
}); });
}();

View File

@ -1,10 +1,8 @@
'use strict'; var http = require('http');
var formidable = require('formidable');
var http = require('http'), var fs = require('fs');
formidable = require('formidable'), var _ = require('underscore');
fs = require('fs'), var util = require('util');
_ = require('lodash');
var options = { var options = {
host: 'localhost', host: 'localhost',
@ -41,6 +39,7 @@ var server = http.createServer(function(req,res) {
output[i] = {}; output[i] = {};
// This is fucking async
fs.readFile(files[i].path, function (err, data) { fs.readFile(files[i].path, function (err, data) {
output[i].type = files[i].type; output[i].type = files[i].type;
@ -49,16 +48,17 @@ var server = http.createServer(function(req,res) {
output[i].lastModifiedDate = files[i].lastModifiedDate; output[i].lastModifiedDate = files[i].lastModifiedDate;
output[i].data = 'data:' + files[i].type + ';base64,' + data.toString('base64'); output[i].data = 'data:' + files[i].type + ';base64,' + data.toString('base64');
console.info(output);
res.end(JSON.stringify(output));
}); });
} }
} }
} } else {
console.info(output); console.info(output);
res.end(JSON.stringify(output)); res.end(JSON.stringify(output));
}
}); });
@ -83,4 +83,4 @@ function unflatten(obj, output) {
} }
server.listen(options.port, options.host); server.listen(options.port, options.host);
console.log("listening on " + options.host + ':' + options.port); console.info("listening on " + options.host + ':' + options.port);