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(){
'use strict';
var $ = require('jquery');
var Backbone = require('backbone');
var _ = require('underscore');
require('../backbone-model-file-upload');
var Blob = require('blob');
describe('Testing Backbone Model Plugin', function () {
@ -293,5 +296,3 @@
});
}();

View File

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