Compare commits

...

7 Commits

Author SHA1 Message Date
nobuti c2232a6d01 Fix mock server to fix specs.
7 years ago
nobuti 8fd20a0f35 Fix dependencies.
7 years ago
nobuti a1dc06cf4b Get rid of bower.
7 years ago
nobuti 33a766a342 Fix package.json
7 years ago
xavijam 9b7ca3dac5 Setting newer version for grunt-contrib-jasmine
8 years ago
nobuti ff2c75cdf7 More fix.
8 years ago
nobuti af329465c9 Fix dependency.
8 years ago

@ -1,3 +1,5 @@
var webpackConfig = require('./webpack.config');
module.exports = function(grunt) {
grunt.initConfig({
@ -8,78 +10,67 @@ module.exports = function(grunt) {
}
},
stop_node: { stop: {} },
run: {
installBower: {
cmd: 'node',
args: [
'./node_modules/bower/bin/bower',
'install'
]
},
killAllNodeWindows: {
cmd: 'taskkill',
args: [
'/f',
'/im',
'node.exe'
]
},
killAllNodeMac: {
cmd: 'killall',
args: [
'node'
]
}
stop_node: {
stop: {}
},
jasmine: {
amd: {
src: 'backbone-model-file-upload.js',
host: 'http://localhost:8888/',
headless: {
options: {
specs: ['test/*spec.js'],
helpers: 'bower_components/Blob/Blob.js',
//keepRunner: true,
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig: {
paths: {
"jquery": "bower_components/jquery/dist/jquery.min",
"underscore": "bower_components/underscore/underscore-min",
"backbone": "bower_components/backbone/backbone"
}
browser: 'chrome',
headless: true,
timeout: 20000,
keepRunner: true,
outfile: '_SpecRunner.html',
host: 'http://localhost:8088',
summary: true,
display: 'short',
reportSlowerThan: 2000,
specs: [
'.grunt/tests.specs.js'
]
}
}
},
connect: {
test: {
options: {
port: 8088,
livereload: false,
hostname: '0.0.0.0', // to be able to access the server not only from localhost
base: {
path: '.'
}
}
},
browserGlobal: {
src: 'backbone-model-file-upload.js',
host: 'http://localhost:8888/',
specs: {
options: {
specs: ['test/*spec.js'],
//keepRunner: true,
vendor: [
"bower_components/Blob/Blob.js",
"bower_components/jquery/dist/jquery.min.js",
"bower_components/underscore/underscore-min.js",
"bower_components/backbone/backbone.js"
]
port: 8088,
livereload: false,
open: 'http://localhost:8088/_SpecRunner.html',
hostname: '0.0.0.0',
base: {
path: '.'
}
}
}
},
webpack: {
options: {
stats: false
},
test: webpackConfig
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-webpack');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-run-node');
grunt.registerTask('test', ['build','run_node','jasmine','stop_node']);
grunt.registerTask('build', ['run:installBower']);
grunt.registerTask('resetNodeWin', ['run:killAllNodeWindows']);
grunt.registerTask('resetNodeMac', ['run:killAllNodeMac']);
grunt.registerTask('test', ['webpack:test', 'connect:test', 'run_node','jasmine','stop_node']);
grunt.registerTask('test:browser', ['webpack:test', 'connect:specs', 'run_node','jasmine','stop_node']);
};

@ -1,24 +0,0 @@
{
"name": "backbone-model-file-upload",
"description": "A concise, non-iframe, & pure XHR2/AJAX Backbone.model file upload. (Good for IE >= 10, FF, Chrome.)",
"version": "1.0.0",
"main": "backbone-model-file-upload.js",
"keywords": [
"backbone",
"fileupload",
"file",
"model",
"multipart"
],
"author": "Joe Vu",
"license": "MIT",
"bugs": {
"url": "https://github.com/homeslicesolutions/backbone-model-file-upload/issues"
},
"homepage": "https://github.com/homeslicesolutions/backbone-model-file-upload",
"dependencies": {
"jquery": "~2.1.1",
"backbone": "~1.1.2",
"Blob": "*"
}
}

@ -6,16 +6,6 @@
"directories": {
"test": "test"
},
"dependencies": {
"bower": "^1.3.12",
"formidable": "~1.0.15",
"grunt": "^0.4.5",
"grunt-contrib-jasmine": "^0.6.5",
"grunt-run": "^0.3.0",
"grunt-run-node": "^0.1.0",
"grunt-template-jasmine-requirejs": "^0.2.0",
"lodash": "~2.4.1"
},
"scripts": {
"test": "grunt test"
},
@ -36,5 +26,19 @@
"url": "https://github.com/homeslicesolutions/backbone-model-file-upload/issues"
},
"homepage": "https://github.com/homeslicesolutions/backbone-model-file-upload",
"devDependencies": {}
"devDependencies": {
"backbone": "1.2.3",
"blob": "0.0.4",
"grunt": "0.4.5",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-jasmine": "CartoDB/grunt-contrib-jasmine#headless-chrome",
"grunt-run": "0.3.0",
"grunt-run-node": "0.1.3",
"grunt-template-jasmine-requirejs": "^0.2.0",
"grunt-webpack": "^3.0.2",
"jquery": "2.1.4",
"underscore": "1.8.3",
"webpack": "^3.5.5",
"formidable": "~1.0.15"
}
}

@ -1,7 +1,10 @@
!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(){
describe('Testing Backbone Model Plugin', function () {
Backbone.$.ajaxSetup({
headers: {
@ -19,7 +22,7 @@
var fileModel;
var simulatedFileObj;
beforeEach(function(){
beforeEach(function () {
simulatedFileObj = new Blob(['<strong>Hello World</strong>'], {type : 'text/html'});
@ -41,7 +44,7 @@
});
it('should detect the file(blob) save successfully', function(done){
it('should detect the file(blob) save successfully', function (done) {
// Arrange
fileModel.set({fileAttachment: simulatedFileObj});
@ -66,7 +69,7 @@
});
it ('should be able to be saved in as an argument of "save" as object', function(done){
it ('should be able to be saved in as an argument of "save" as object', function (done) {
// Listen
fileModel.on('sync', function(model){
@ -88,7 +91,7 @@
});
it ('should be able to be saved in as an argument of "save" as key/value argument', function(done){
it ('should be able to be saved in as an argument of "save" as key/value argument', function (done) {
// Listen
fileModel.on('sync', function(model){
@ -109,7 +112,7 @@
});
it ('should be able to have "wait" and "validate" option', function(done){
it ('should be able to have "wait" and "validate" option', function (done) {
// Listen
fileModel.on('sync', function(model){
@ -130,7 +133,7 @@
});
it('should still have the option to save normally by setting it and save(null)', function(done){
it('should still have the option to save normally by setting it and save(null)', function (done) {
// Listen
fileModel.on('sync', function(model){
@ -149,7 +152,7 @@
});
it('should still have the option to save normally by save("from","yes")', function(done){
it('should still have the option to save normally by save("from","yes")', function (done) {
// Listen
fileModel.on('sync', function(model){
@ -167,7 +170,7 @@
});
it('should still have the option to save normally by save({from: "yes"})', function(done){
it('should still have the option to save normally by save({from: "yes"})', function (done) {
// Listen
fileModel.on('sync', function(model){
@ -185,7 +188,7 @@
});
it('should still silent true with file', function(done){
it('should still silent true with file', function (done) {
var changed = false;
@ -214,7 +217,7 @@
});
it('should still silent true without file', function(done){
it('should still silent true without file', function (done) {
var changed = false;
@ -240,7 +243,7 @@
});
it('should flatten correctly using a bracket notation', function(){
it('should flatten correctly using a bracket notation', function () {
// Arrange
var expected = {
@ -261,7 +264,7 @@
expect(flattened["nestedObject[nestier[nestiest[2]]]"]).toBe("three");
});
it('should unflatten correctly using internal "unflatten" function', function(){
it('should unflatten correctly using internal "unflatten" function', function () {
var flattened = fileModel._flatten(fileModel.toJSON()),
unflattened = fileModel._unflatten(flattened);
@ -291,7 +294,5 @@
});
});
});
}();

@ -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);

@ -0,0 +1,10 @@
var path = require('path');
module.exports = {
entry: './test/backbone-model-file-upload.spec.js',
output: {
path: path.resolve(path.resolve('.'), '.grunt'),
filename: 'tests.specs.js'
},
devtool: 'inline-source-map'
};
Loading…
Cancel
Save