Commit cd09d5044644d9febf011b53fdb0f46e75306f23
1 parent
56cbcbad48
Exists in
master
unit test
Showing
7 changed files
with
193 additions
and
3 deletions
Show diff stats
gulpfile.js
| 1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
| 2 | const clean = require('gulp-clean'); | 2 | const clean = require('gulp-clean'); |
| 3 | const concat = require('gulp-concat'); | 3 | const concat = require('gulp-concat'); |
| 4 | const htmlmin = require('gulp-htmlmin'); | 4 | const htmlmin = require('gulp-htmlmin'); |
| 5 | const rename = require('gulp-rename'); | 5 | const rename = require('gulp-rename'); |
| 6 | const uglify = require('gulp-uglify'); | 6 | const uglify = require('gulp-uglify'); |
| 7 | const gulp = require('gulp'); | 7 | const gulp = require('gulp'); |
| 8 | const pump = require('pump'); | 8 | const pump = require('pump'); |
| 9 | const jshint = require('gulp-jshint'); | 9 | const jshint = require('gulp-jshint'); |
| 10 | const replace = require('gulp-replace'); | 10 | const replace = require('gulp-replace'); |
| 11 | const connect = require('gulp-connect'); | 11 | const connect = require('gulp-connect'); |
| 12 | 12 | ||
| 13 | var paths = { | 13 | var paths = { |
| 14 | srcJS: 'src/js/*.js', | 14 | srcJS: 'src/js/*.js', |
| 15 | srcViews: 'src/views/*.html', | 15 | srcViews: 'src/views/*.html', |
| 16 | specs: 'spec/*.js', | ||
| 16 | tmp: 'tmp', | 17 | tmp: 'tmp', |
| 17 | dist: 'dist/' | 18 | dist: 'dist/' |
| 18 | }; | 19 | }; |
| 19 | 20 | ||
| 20 | gulp.task('templates', ['clean'], function() { | 21 | gulp.task('templates', ['clean'], function() { |
| 21 | return pump( | 22 | return pump( |
| 22 | [ | 23 | [ |
| 23 | gulp.src(paths.srcViews), | 24 | gulp.src(paths.srcViews), |
| 24 | htmlmin(), | 25 | htmlmin(), |
| 25 | templateCache('views.js', { | 26 | templateCache('views.js', { |
| 26 | module: 'focaCrearCobranza', | 27 | module: 'focaCrearCobranza', |
| 27 | root: '' | 28 | root: '' |
| 28 | }), | 29 | }), |
| 29 | gulp.dest(paths.tmp) | 30 | gulp.dest(paths.tmp) |
| 30 | ] | 31 | ] |
| 31 | ); | 32 | ); |
| 32 | }); | 33 | }); |
| 33 | 34 | ||
| 34 | gulp.task('uglify', ['templates'], function() { | 35 | gulp.task('uglify', ['templates'], function() { |
| 35 | return pump( | 36 | return pump( |
| 36 | [ | 37 | [ |
| 37 | gulp.src([ | 38 | gulp.src([ |
| 38 | paths.srcJS, | 39 | paths.srcJS, |
| 39 | 'tmp/views.js' | 40 | 'tmp/views.js' |
| 40 | ]), | 41 | ]), |
| 41 | concat('foca-crear-cobranza.js'), | 42 | concat('foca-crear-cobranza.js'), |
| 42 | replace('src/views/', ''), | 43 | replace('src/views/', ''), |
| 43 | gulp.dest(paths.tmp), | 44 | gulp.dest(paths.tmp), |
| 44 | rename('foca-crear-cobranza.min.js'), | 45 | rename('foca-crear-cobranza.min.js'), |
| 45 | uglify(), | 46 | uglify(), |
| 46 | gulp.dest(paths.dist) | 47 | gulp.dest(paths.dist) |
| 47 | 48 | ||
| 48 | ] | 49 | ] |
| 49 | ); | 50 | ); |
| 50 | }); | 51 | }); |
| 51 | 52 | ||
| 52 | gulp.task('clean', function() { | 53 | gulp.task('clean', function() { |
| 53 | return gulp.src(['tmp', 'dist'], {read: false}) | 54 | return gulp.src(['tmp', 'dist'], {read: false}) |
| 54 | .pipe(clean()); | 55 | .pipe(clean()); |
| 55 | }); | 56 | }); |
| 56 | 57 | ||
| 57 | gulp.task('pre-commit', function() { | 58 | gulp.task('pre-commit', function() { |
| 58 | return pump( | 59 | return pump( |
| 59 | [ | 60 | [ |
| 60 | gulp.src(paths.srcJS), | 61 | gulp.src([paths.srcJS, paths.specs]), |
| 61 | jshint('.jshintrc'), | 62 | jshint('.jshintrc'), |
| 62 | jshint.reporter('default'), | 63 | jshint.reporter('default'), |
| 63 | jshint.reporter('fail') | 64 | jshint.reporter('fail') |
| 64 | ] | 65 | ] |
| 65 | ); | 66 | ); |
| 66 | 67 | ||
| 67 | gulp.start('uglify'); | 68 | gulp.start('uglify'); |
| 68 | }); | 69 | }); |
| 69 | 70 | ||
| 70 | gulp.task('webserver', function() { | 71 | gulp.task('webserver', function() { |
| 71 | pump [ | 72 | pump [ |
| 72 | connect.server({port: 3300, host: '0.0.0.0'}) | 73 | connect.server({port: 3300, host: '0.0.0.0'}) |
| 73 | ] | 74 | ] |
| 74 | }); | 75 | }); |
| 75 | 76 | ||
| 76 | gulp.task('clean-post-install', function() { | 77 | gulp.task('clean-post-install', function() { |
| 77 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 78 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
| 78 | 'index.html'], {read: false}) | 79 | 'index.html'], {read: false}) |
| 79 | .pipe(clean()); | 80 | .pipe(clean()); |
| 80 | }); | 81 | }); |
| 81 | 82 | ||
| 82 | gulp.task('default', ['webserver']); | 83 | gulp.task('default', ['webserver']); |
| 83 | 84 | ||
| 84 | gulp.task('watch', function() { | 85 | gulp.task('watch', function() { |
| 85 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 86 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
| 86 | }); | 87 | }); |
| 87 | 88 |
package.json
| 1 | { | 1 | { |
| 2 | "name": "foca-crear-cobranza", | 2 | "name": "foca-crear-cobranza", |
| 3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
| 4 | "description": "sistema de cobranzas a partir de facturas", | 4 | "description": "sistema de cobranzas a partir de facturas", |
| 5 | "main": "index.js", | 5 | "main": "index.js", |
| 6 | "scripts": { | 6 | "scripts": { |
| 7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "test.html", |
| 8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
| 9 | "gulp-pre-commit": "gulp pre-commit", | 9 | "gulp-pre-commit": "gulp pre-commit", |
| 10 | "postinstall": "npm run compile && gulp clean-post-install", | 10 | "postinstall": "npm run compile && gulp clean-post-install", |
| 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-factura.git git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git git+http://git.focasoftware.com/npm/foca-directivas.git" | 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-factura.git git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git git+http://git.focasoftware.com/npm/foca-directivas.git" |
| 12 | }, | 12 | }, |
| 13 | "pre-commit": [ | 13 | "pre-commit": [ |
| 14 | "gulp-pre-commit" | 14 | "gulp-pre-commit" |
| 15 | ], | 15 | ], |
| 16 | "repository": { | 16 | "repository": { |
| 17 | "type": "git", | 17 | "type": "git", |
| 18 | "url": "http://git.focasoftware.com/npm/foca-crear-cobranza.git" | 18 | "url": "http://git.focasoftware.com/npm/foca-crear-cobranza.git" |
| 19 | }, | 19 | }, |
| 20 | "author": "Foca Software", | 20 | "author": "Foca Software", |
| 21 | "license": "ISC", | 21 | "license": "ISC", |
| 22 | "devDependencies": { | 22 | "devDependencies": { |
| 23 | "angular": "^1.7.5", | 23 | "angular": "^1.7.5", |
| 24 | "angular-ladda": "^0.4.3", | 24 | "angular-ladda": "^0.4.3", |
| 25 | "angular-mocks": "^1.7.7", | ||
| 25 | "angular-route": "^1.7.5", | 26 | "angular-route": "^1.7.5", |
| 26 | "bootstrap": "^4.1.3", | 27 | "bootstrap": "^4.1.3", |
| 27 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", | 28 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", |
| 28 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", | 29 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", |
| 29 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 30 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
| 30 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 31 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
| 31 | "foca-modal-factura": "git+http://git.focasoftware.com/npm/foca-modal-factura.git", | 32 | "foca-modal-factura": "git+http://git.focasoftware.com/npm/foca-modal-factura.git", |
| 32 | "font-awesome": "^4.7.0", | 33 | "font-awesome": "^4.7.0", |
| 33 | "gulp": "^3.9.1", | 34 | "gulp": "^3.9.1", |
| 34 | "gulp-angular-templatecache": "^2.2.5", | 35 | "gulp-angular-templatecache": "^2.2.5", |
| 35 | "gulp-clean": "^0.4.0", | 36 | "gulp-clean": "^0.4.0", |
| 36 | "gulp-concat": "^2.6.1", | 37 | "gulp-concat": "^2.6.1", |
| 37 | "gulp-connect": "^5.6.1", | 38 | "gulp-connect": "^5.6.1", |
| 38 | "gulp-htmlmin": "^5.0.1", | 39 | "gulp-htmlmin": "^5.0.1", |
| 39 | "gulp-jshint": "^2.1.0", | 40 | "gulp-jshint": "^2.1.0", |
| 40 | "gulp-rename": "^1.4.0", | 41 | "gulp-rename": "^1.4.0", |
| 41 | "gulp-replace": "^1.0.0", | 42 | "gulp-replace": "^1.0.0", |
| 42 | "gulp-sequence": "^1.0.0", | 43 | "gulp-sequence": "^1.0.0", |
| 43 | "gulp-uglify": "^3.0.1", | 44 | "gulp-uglify": "^3.0.1", |
| 44 | "gulp-uglify-es": "^1.0.4", | 45 | "gulp-uglify-es": "^1.0.4", |
| 45 | "jasmine-core": "^3.3.0", | 46 | "jasmine-core": "^3.3.0", |
| 46 | "jquery": "^3.3.1", | 47 | "jquery": "^3.3.1", |
| 47 | "jshint": "^2.9.6", | 48 | "jshint": "^2.9.6", |
| 48 | "ladda": "1.0.6", | 49 | "ladda": "1.0.6", |
| 49 | "pre-commit": "^1.2.2", | 50 | "pre-commit": "^1.2.2", |
| 50 | "pump": "^3.0.0", | 51 | "pump": "^3.0.0", |
| 51 | "ui-bootstrap4": "^3.0.5" | 52 | "ui-bootstrap4": "^3.0.5" |
| 52 | } | 53 | } |
| 53 | } | 54 | } |
| 54 | 55 |
spec/controllerSpec.js
spec/routeSpec.js
| File was created | 1 | describe('rutas del módulo crear cobranza', function() { | |
| 2 | |||
| 3 | var route; | ||
| 4 | |||
| 5 | beforeEach(function() { | ||
| 6 | |||
| 7 | module('focaCrearCobranza'); | ||
| 8 | inject(function($route) { | ||
| 9 | route = $route; | ||
| 10 | }); | ||
| 11 | }); | ||
| 12 | |||
| 13 | it('route /cobranza/crear lleva a ctrl y template correcto', function() { | ||
| 14 | |||
| 15 | //assert | ||
| 16 | expect(route.routes['/cobranza/crear'].controller).toBe('cobranzaController'); | ||
| 17 | expect(route.routes['/cobranza/crear'].templateUrl).toBe('src/views/cobranza.html'); | ||
| 18 | }); | ||
| 19 | }); |
spec/serviceSpec.js
| File was created | 1 | describe('Servicios módulo crear cobranza', function() { | |
| 2 | |||
| 3 | beforeEach(function() { | ||
| 4 | |||
| 5 | module('focaCrearCobranza'); | ||
| 6 | |||
| 7 | inject(module(function($provide) { | ||
| 8 | $provide.value('API_ENDPOINT', { | ||
| 9 | URL: 'localhost' | ||
| 10 | }); | ||
| 11 | })); | ||
| 12 | }); | ||
| 13 | |||
| 14 | describe('servicio focaCrearCobranzaService', function() { | ||
| 15 | |||
| 16 | var servicio; | ||
| 17 | var httpBackend; | ||
| 18 | |||
| 19 | beforeEach(function() { | ||
| 20 | inject(function($httpBackend, _focaCrearCobranzaService_) { | ||
| 21 | httpBackend = $httpBackend; | ||
| 22 | servicio = _focaCrearCobranzaService_; | ||
| 23 | }); | ||
| 24 | }); | ||
| 25 | |||
| 26 | it('existe el servicio focaCrearCobranzaService', function() { | ||
| 27 | |||
| 28 | //assert | ||
| 29 | expect(typeof servicio).toEqual('object'); | ||
| 30 | }); | ||
| 31 | |||
| 32 | it('getNumeroRecibo llama a ruta correcta', function() { | ||
| 33 | |||
| 34 | //arrange | ||
| 35 | var responseFake = 'responseFake'; | ||
| 36 | var result; | ||
| 37 | |||
| 38 | httpBackend.expectGET('localhost/recibo/numero-siguiente').respond(responseFake); | ||
| 39 | |||
| 40 | //act | ||
| 41 | servicio.getNumeroRecibo().then(function(data) { | ||
| 42 | result = data.data; | ||
| 43 | }); | ||
| 44 | httpBackend.flush(); | ||
| 45 | |||
| 46 | //assert | ||
| 47 | expect(result).toEqual(responseFake); | ||
| 48 | }); | ||
| 49 | |||
| 50 | it('getCotizacionByIdMoneda llama a ruta correcta', function() { | ||
| 51 | |||
| 52 | //arrange | ||
| 53 | var responseFake = 'responseFake'; | ||
| 54 | var result; | ||
| 55 | var paramFake = 1; | ||
| 56 | |||
| 57 | httpBackend.expectGET('localhost/moneda/' + paramFake).respond(responseFake); | ||
| 58 | |||
| 59 | //act | ||
| 60 | servicio.getCotizacionByIdMoneda(paramFake).then(function(data) { | ||
| 61 | result = data.data; | ||
| 62 | }); | ||
| 63 | httpBackend.flush(); | ||
| 64 | |||
| 65 | //assert | ||
| 66 | expect(result).toEqual(responseFake); | ||
| 67 | }); | ||
| 68 | |||
| 69 | it('guardarCobranza llama a ruta correcta', function() { | ||
| 70 | |||
| 71 | //arrange | ||
| 72 | var responseFake = 'responseFake'; | ||
| 73 | var result; | ||
| 74 | var paramFake = 1; | ||
| 75 | |||
| 76 | httpBackend.expectPOST('localhost/recibo/guardar', paramFake).respond(responseFake); | ||
| 77 | |||
| 78 | //act | ||
| 79 | servicio.guardarCobranza(paramFake).then(function(data) { | ||
| 80 | result = data.data; | ||
| 81 | }); | ||
| 82 | httpBackend.flush(); | ||
| 83 | |||
| 84 | //assert | ||
| 85 | expect(result).toEqual(responseFake); | ||
| 86 | }); | ||
| 87 | |||
| 88 | it('getCobradorById llama a ruta correcta', function() { | ||
| 89 | |||
| 90 | //arrange | ||
| 91 | var responseFake = 'responseFake'; | ||
| 92 | var result; | ||
| 93 | var paramFake = 1; | ||
| 94 | |||
| 95 | httpBackend.expectGET('localhost/vendedor-cobrador/' + paramFake).respond(responseFake); | ||
| 96 | |||
| 97 | //act | ||
| 98 | servicio.getCobradorById(paramFake).then(function(data) { | ||
| 99 | result = data.data; | ||
| 100 | }); | ||
| 101 | httpBackend.flush(); | ||
| 102 | |||
| 103 | //assert | ||
| 104 | expect(result).toEqual(responseFake); | ||
| 105 | }); | ||
| 106 | |||
| 107 | it('enviarComprobantePorMail llama a ruta correcta', function() { | ||
| 108 | |||
| 109 | //arrange | ||
| 110 | var responseFake = 'responseFake'; | ||
| 111 | var result; | ||
| 112 | var paramFake = 1; | ||
| 113 | |||
| 114 | httpBackend.expectPOST('localhost/mail/comprobante', | ||
| 115 | {receiver: paramFake}).respond(responseFake); | ||
| 116 | |||
| 117 | //act | ||
| 118 | servicio.enviarComprobantePorMail(paramFake).then(function(data) { | ||
| 119 | result = data.data; | ||
| 120 | }); | ||
| 121 | httpBackend.flush(); | ||
| 122 | |||
| 123 | //assert | ||
| 124 | expect(result).toEqual(responseFake); | ||
| 125 | }); | ||
| 126 | |||
| 127 | it('actualizarEmail llama a ruta correcta', function() { | ||
| 128 | |||
| 129 | //arrange | ||
| 130 | var responseFake = 'responseFake'; | ||
| 131 | var result; | ||
| 132 | var paramFake = 1; | ||
| 133 | |||
| 134 | httpBackend.expectPOST('localhost/cliente/update/email', | ||
| 135 | {mail: paramFake}).respond(responseFake); | ||
| 136 | |||
| 137 | //act | ||
| 138 | servicio.actualizarEmail(paramFake).then(function(data) { | ||
| 139 | result = data.data; | ||
| 140 | }); | ||
| 141 | httpBackend.flush(); | ||
| 142 | |||
| 143 | //assert | ||
| 144 | expect(result).toEqual(responseFake); | ||
| 145 | }); | ||
| 146 | }); | ||
| 147 | |||
| 148 | }); |
src/js/app.js
| 1 | angular.module('focaCrearCobranza', []); | 1 | angular.module('focaCrearCobranza', ['ngRoute']); |
| 2 | 2 |
test.html
| File was created | 1 | <html> | |
| 2 | <head> | ||
| 3 | <link rel="stylesheet" type="text/css" href="node_modules/jasmine-core/lib/jasmine-core/jasmine.css"> | ||
| 4 | <meta charset="UTF-8" /> | ||
| 5 | </head> | ||
| 6 | <body> | ||
| 7 | <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script> | ||
| 8 | <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script> | ||
| 9 | <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/boot.js"></script> | ||
| 10 | <script type="text/javascript" src="node_modules/angular/angular.min.js"></script> | ||
| 11 | <script type="text/javascript" src="node_modules/angular-route/angular-route.min.js"></script> | ||
| 12 | <script type="text/javascript" src="node_modules/angular-mocks/angular-mocks.js"></script> | ||
| 13 | <script type="text/javascript" src="src/js/app.js"></script> | ||
| 14 | <script type="text/javascript" src="src/js/controller.js"></script> | ||
| 15 | <script type="text/javascript" src="src/js/service.js"></script> | ||
| 16 | <script type="text/javascript" src="src/js/route.js"></script> | ||
| 17 | <script type="text/javascript" src="spec/controllerSpec.js"></script> | ||
| 18 | <script type="text/javascript" src="spec/serviceSpec.js"></script> | ||
| 19 | <script type="text/javascript" src="spec/routeSpec.js"></script> | ||
| 20 | </body> | ||
| 21 | </html> | ||
| 22 |