Commit 0fdf7f0a11d5bfe0d41c1d2967ba0e3ce49fb7be
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request !11
Showing
7 changed files
 
Show diff stats
gulpfile.js
| ... | ... | @@ -9,10 +9,13 @@ const jshint = require('gulp-jshint'); | 
| 9 | 9 | const replace = require('gulp-replace'); | 
| 10 | 10 | const connect = require('gulp-connect'); | 
| 11 | 11 | const clean = require('gulp-clean'); | 
| 12 | +const header = require('gulp-header'); | |
| 13 | +const footer =require('gulp-footer'); | |
| 12 | 14 | |
| 13 | 15 | var paths = { | 
| 14 | 16 | srcJS: 'src/js/*.js', | 
| 15 | 17 | srcViews: 'src/views/*.html', | 
| 18 | + specs: 'spec/*.js', | |
| 16 | 19 | tmp: 'tmp', | 
| 17 | 20 | dist: 'dist/' | 
| 18 | 21 | }; | 
| ... | ... | @@ -32,7 +35,7 @@ gulp.task('templates', function() { | 
| 32 | 35 | ); | 
| 33 | 36 | }); | 
| 34 | 37 | |
| 35 | -gulp.task('uglify', ['templates'], function() { | |
| 38 | +gulp.task('uglify', ['templates', 'uglify-spec'], function() { | |
| 36 | 39 | return pump( | 
| 37 | 40 | [ | 
| 38 | 41 | gulp.src([ | 
| ... | ... | @@ -49,6 +52,17 @@ gulp.task('uglify', ['templates'], function() { | 
| 49 | 52 | ); | 
| 50 | 53 | }); | 
| 51 | 54 | |
| 55 | +gulp.task('uglify-spec', function() { | |
| 56 | + return pump([ | |
| 57 | + gulp.src(paths.specs), | |
| 58 | + concat('foca-abm-chofer.spec.js'), | |
| 59 | + replace("src/views/", ''), | |
| 60 | + header("describe('Módulo foca-abm-chofer', function() { \n"), | |
| 61 | + footer("});"), | |
| 62 | + gulp.dest(paths.dist) | |
| 63 | + ]); | |
| 64 | +}); | |
| 65 | + | |
| 52 | 66 | gulp.task('clean', function() { | 
| 53 | 67 | return gulp.src(['tmp', 'dist'], {read: false}) | 
| 54 | 68 | .pipe(clean()); | 
| ... | ... | @@ -57,7 +71,7 @@ gulp.task('clean', function() { | 
| 57 | 71 | gulp.task('pre-commit', function() { | 
| 58 | 72 | pump( | 
| 59 | 73 | [ | 
| 60 | - gulp.src(paths.srcJS), | |
| 74 | + gulp.src([paths.srcJS, paths.specs]), | |
| 61 | 75 | jshint('.jshintrc'), | 
| 62 | 76 | jshint.reporter('default'), | 
| 63 | 77 | jshint.reporter('fail') | 
| ... | ... | @@ -69,7 +83,7 @@ gulp.task('pre-commit', function() { | 
| 69 | 83 | |
| 70 | 84 | gulp.task('clean-post-install', function() { | 
| 71 | 85 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 
| 72 | - 'index.html'], {read: false}) | |
| 86 | + 'index.html', 'spec'], {read: false}) | |
| 73 | 87 | .pipe(clean()); | 
| 74 | 88 | }); | 
| 75 | 89 | 
package.json
| ... | ... | @@ -4,7 +4,7 @@ | 
| 4 | 4 | "description": "Abm de chofer", | 
| 5 | 5 | "main": "index.html", | 
| 6 | 6 | "scripts": { | 
| 7 | - "test": "echo \"Error: no test specified\" && exit 1", | |
| 7 | + "test": "test.html", | |
| 8 | 8 | "compile": "gulp uglify", | 
| 9 | 9 | "gulp-pre-commit": "gulp pre-commit", | 
| 10 | 10 | "postinstall": "npm run compile && gulp clean-post-install", | 
| ... | ... | @@ -36,7 +36,8 @@ | 
| 36 | 36 | }, | 
| 37 | 37 | "devDependencies": { | 
| 38 | 38 | "angular": "^1.7.7", | 
| 39 | - "angular-route": "^1.7.5", | |
| 39 | + "angular-mocks": "^1.7.7", | |
| 40 | + "angular-route": "^1.7.7", | |
| 40 | 41 | "bootstrap": "^4.2.1", | 
| 41 | 42 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 
| 42 | 43 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 
| ... | ... | @@ -45,6 +46,7 @@ | 
| 45 | 46 | "gulp-angular-templatecache": "^2.2.6", | 
| 46 | 47 | "gulp-clean": "^0.4.0", | 
| 47 | 48 | "gulp-connect": "^5.7.0", | 
| 49 | + "gulp-header": "^2.0.7", | |
| 48 | 50 | "gulp-htmlmin": "^5.0.1", | 
| 49 | 51 | "gulp-jshint": "^2.1.0", | 
| 50 | 52 | "gulp-rename": "^1.4.0", | 
spec/controllerSpec.js
| ... | ... | @@ -0,0 +1,304 @@ | 
| 1 | +describe('Controladores de abm chofer', function() { | |
| 2 | + | |
| 3 | + var $controller; | |
| 4 | + | |
| 5 | + beforeEach(function() { | |
| 6 | + module('focaAbmChofer'); | |
| 7 | + inject(function(_$controller_) { | |
| 8 | + $controller = _$controller_; | |
| 9 | + }); | |
| 10 | + }); | |
| 11 | + | |
| 12 | + describe('Controlador focaAbmChoferesController', function() { | |
| 13 | + | |
| 14 | + it('Existe el controlador focaAbmChoferesController', function() { | |
| 15 | + //arrange | |
| 16 | + var controlador = $controller('focaAbmChoferesController', { | |
| 17 | + $scope: {}, | |
| 18 | + focaAbmChoferService: { | |
| 19 | + transportistaSeleccionado: function() { return; } | |
| 20 | + }, | |
| 21 | + $location: {}, | |
| 22 | + $uibModal: {}, | |
| 23 | + focaModalService: {}, | |
| 24 | + focaBotoneraLateralService: {}, | |
| 25 | + $timeout: function() { return; } | |
| 26 | + }); | |
| 27 | + | |
| 28 | + //assert | |
| 29 | + expect(typeof controlador).toEqual('object'); | |
| 30 | + }); | |
| 31 | + | |
| 32 | + it('$scope.solicitarConfirmacion levanta modal de confirmacion', function() { | |
| 33 | + //arrange | |
| 34 | + var fakeParam = ''; | |
| 35 | + var scope = {}; | |
| 36 | + var focaModalService = { | |
| 37 | + confirm: function() { } | |
| 38 | + }; | |
| 39 | + var controlador = $controller('focaAbmChoferesController', { | |
| 40 | + $scope: scope, | |
| 41 | + focaAbmChoferService: { | |
| 42 | + transportistaSeleccionado: function() { return; } | |
| 43 | + }, | |
| 44 | + $location: {}, | |
| 45 | + $uibModal: {}, | |
| 46 | + focaModalService: focaModalService, | |
| 47 | + focaBotoneraLateralService: {}, | |
| 48 | + $timeout: function() { return; } | |
| 49 | + }); | |
| 50 | + console.info(controlador); | |
| 51 | + | |
| 52 | + //act | |
| 53 | + spyOn(focaModalService, 'confirm').and.returnValue({ then: function() { }}); | |
| 54 | + scope.solicitarConfirmacion(fakeParam); | |
| 55 | + | |
| 56 | + //assert | |
| 57 | + expect(focaModalService.confirm).toHaveBeenCalled(); | |
| 58 | + }); | |
| 59 | + | |
| 60 | + it('$scope.solicitarConfirmacion elimina al confirmar', function(done) { | |
| 61 | + //arrange | |
| 62 | + var scope = {}; | |
| 63 | + var focaModalService = { | |
| 64 | + confirm: function() { | |
| 65 | + return { | |
| 66 | + then: function() { } | |
| 67 | + }; | |
| 68 | + } | |
| 69 | + }; | |
| 70 | + var focaAbmChoferService = { | |
| 71 | + transportistaSeleccionado: function() { return; }, | |
| 72 | + deleteChofer: function() { } | |
| 73 | + }; | |
| 74 | + var controlador = $controller('focaAbmChoferesController', { | |
| 75 | + $scope: scope, | |
| 76 | + focaAbmChoferService: focaAbmChoferService, | |
| 77 | + $location: {}, | |
| 78 | + $uibModal: {}, | |
| 79 | + focaModalService: focaModalService, | |
| 80 | + focaBotoneraLateralService: {}, | |
| 81 | + $timeout: function() { return; } | |
| 82 | + }); | |
| 83 | + console.info(controlador); | |
| 84 | + var fakeParam = ''; | |
| 85 | + var promesa = Promise.resolve(true); | |
| 86 | + | |
| 87 | + //act | |
| 88 | + spyOn(focaModalService, 'confirm').and.returnValue(promesa); | |
| 89 | + spyOn(focaAbmChoferService, 'deleteChofer'); | |
| 90 | + scope.solicitarConfirmacion(fakeParam); | |
| 91 | + | |
| 92 | + //assert | |
| 93 | + promesa.then(function() { | |
| 94 | + expect(focaAbmChoferService.deleteChofer).toHaveBeenCalled(); | |
| 95 | + done(); | |
| 96 | + }); | |
| 97 | + }); | |
| 98 | + | |
| 99 | + it('$scope.seleccionarTransportista levanta modal', function() { | |
| 100 | + //arrange | |
| 101 | + var scope = {}; | |
| 102 | + var focaModalService = { | |
| 103 | + modal: function() { } | |
| 104 | + }; | |
| 105 | + var controlador = $controller('focaAbmChoferesController', { | |
| 106 | + $scope: scope, | |
| 107 | + focaAbmChoferService: { | |
| 108 | + transportistaSeleccionado: function() { } | |
| 109 | + }, | |
| 110 | + $location: {}, | |
| 111 | + $uibModal: {}, | |
| 112 | + focaModalService: focaModalService, | |
| 113 | + focaBotoneraLateralService: {}, | |
| 114 | + $timeout: function() { return; } | |
| 115 | + }); | |
| 116 | + console.info(controlador); | |
| 117 | + | |
| 118 | + //act | |
| 119 | + spyOn(focaModalService, 'modal').and.returnValue({ then: function() { }}); | |
| 120 | + scope.seleccionarTransportista(); | |
| 121 | + | |
| 122 | + //assert | |
| 123 | + expect(focaModalService.modal).toHaveBeenCalled(); | |
| 124 | + }); | |
| 125 | + }); | |
| 126 | + | |
| 127 | + describe('Controlador focaAbmChoferController', function() { | |
| 128 | + | |
| 129 | + it('Existe el controlador focaAbmChoferController', function() { | |
| 130 | + //arrange | |
| 131 | + var controlador = $controller('focaAbmChoferController', { | |
| 132 | + $scope: {}, | |
| 133 | + focaAbmChoferService: { | |
| 134 | + getTiposDocumento: function() { | |
| 135 | + return { | |
| 136 | + then: function() { } | |
| 137 | + }; | |
| 138 | + }, | |
| 139 | + getChofer: function() { | |
| 140 | + return { | |
| 141 | + then: function() { } | |
| 142 | + }; | |
| 143 | + }, | |
| 144 | + getTransportistas: function() { | |
| 145 | + return { | |
| 146 | + then: function() { } | |
| 147 | + }; | |
| 148 | + } | |
| 149 | + }, | |
| 150 | + $routeParams: {}, | |
| 151 | + $location: {}, | |
| 152 | + focaBotoneraLateralService: {}, | |
| 153 | + $timeout: function() { return; }, | |
| 154 | + focaModalService: {} | |
| 155 | + }); | |
| 156 | + | |
| 157 | + //assert | |
| 158 | + expect(typeof controlador).toEqual('object'); | |
| 159 | + }); | |
| 160 | + | |
| 161 | + it('$scope.cancelar lleva a la ruta correcta', function() { | |
| 162 | + inject(function($location) { | |
| 163 | + //arrange | |
| 164 | + var scope = {}; | |
| 165 | + var controlador = $controller('focaAbmChoferController', { | |
| 166 | + $scope: scope, | |
| 167 | + focaAbmChoferService: { | |
| 168 | + getTiposDocumento: function() { | |
| 169 | + return { | |
| 170 | + then: function() { } | |
| 171 | + }; | |
| 172 | + }, | |
| 173 | + getChofer: function() { | |
| 174 | + return { | |
| 175 | + then: function() { } | |
| 176 | + }; | |
| 177 | + }, | |
| 178 | + getTransportistas: function() { | |
| 179 | + return { | |
| 180 | + then: function() { } | |
| 181 | + }; | |
| 182 | + } | |
| 183 | + }, | |
| 184 | + $routeParams: {}, | |
| 185 | + $location: $location, | |
| 186 | + focaBotoneraLateralService: {}, | |
| 187 | + $timeout: function() { return; }, | |
| 188 | + focaModalService: {} | |
| 189 | + }); | |
| 190 | + console.info(controlador); | |
| 191 | + | |
| 192 | + //act | |
| 193 | + scope.cancelar(); | |
| 194 | + | |
| 195 | + //assert | |
| 196 | + expect($location.url()).toEqual('/chofer'); | |
| 197 | + }); | |
| 198 | + }); | |
| 199 | + | |
| 200 | + it('$scope.guardar guarda chofer al validarDNI() da ok', function(done) { | |
| 201 | + | |
| 202 | + //arrange | |
| 203 | + var scope = {}; | |
| 204 | + var focaAbmChoferService = { | |
| 205 | + getTiposDocumento: function() { | |
| 206 | + return { | |
| 207 | + then: function() { } | |
| 208 | + }; | |
| 209 | + }, | |
| 210 | + getChofer: function() { | |
| 211 | + return { | |
| 212 | + then: function() { } | |
| 213 | + }; | |
| 214 | + }, | |
| 215 | + getTransportistas: function() { | |
| 216 | + return { | |
| 217 | + then: function() { } | |
| 218 | + }; | |
| 219 | + }, | |
| 220 | + guardarChofer: function() { }, | |
| 221 | + getChoferPorDni: function() { } | |
| 222 | + }; | |
| 223 | + var controlador = $controller('focaAbmChoferController', { | |
| 224 | + $scope: scope, | |
| 225 | + focaAbmChoferService: focaAbmChoferService, | |
| 226 | + $routeParams: {}, | |
| 227 | + $location: {}, | |
| 228 | + focaBotoneraLateralService: {}, | |
| 229 | + $timeout: function() { return; }, | |
| 230 | + focaModalService: {} | |
| 231 | + }); | |
| 232 | + console.info(controlador); | |
| 233 | + var resolveFake = { data: false }; | |
| 234 | + var promesaChoferPorDni = Promise.resolve(resolveFake); | |
| 235 | + | |
| 236 | + //act | |
| 237 | + spyOn(focaAbmChoferService, 'guardarChofer').and.returnValue({ then: function() { }}); | |
| 238 | + spyOn(focaAbmChoferService, 'getChoferPorDni').and.returnValue(promesaChoferPorDni); | |
| 239 | + scope.guardar(13); | |
| 240 | + | |
| 241 | + //assert | |
| 242 | + promesaChoferPorDni.then(function() { | |
| 243 | + setTimeout(function() { | |
| 244 | + expect(focaAbmChoferService.guardarChofer).toHaveBeenCalled(); | |
| 245 | + done(); | |
| 246 | + }); | |
| 247 | + }); | |
| 248 | + }); | |
| 249 | + | |
| 250 | + it('$scope.guardar da alerta chofer al validarDNI() da reject', function(done) { | |
| 251 | + | |
| 252 | + //arrange | |
| 253 | + var scope = {}; | |
| 254 | + var focaModalService = { | |
| 255 | + alert: function() { } | |
| 256 | + }; | |
| 257 | + var focaAbmChoferService = { | |
| 258 | + getTiposDocumento: function() { | |
| 259 | + return { | |
| 260 | + then: function() { } | |
| 261 | + }; | |
| 262 | + }, | |
| 263 | + getChofer: function() { | |
| 264 | + return { | |
| 265 | + then: function() { } | |
| 266 | + }; | |
| 267 | + }, | |
| 268 | + getTransportistas: function() { | |
| 269 | + return { | |
| 270 | + then: function() { } | |
| 271 | + }; | |
| 272 | + }, | |
| 273 | + getChoferPorDni: function() { } | |
| 274 | + }; | |
| 275 | + var controlador = $controller('focaAbmChoferController', { | |
| 276 | + $scope: scope, | |
| 277 | + focaAbmChoferService: focaAbmChoferService, | |
| 278 | + $routeParams: {}, | |
| 279 | + $location: {}, | |
| 280 | + focaBotoneraLateralService: {}, | |
| 281 | + $timeout: function() { return; }, | |
| 282 | + focaModalService: focaModalService | |
| 283 | + }); | |
| 284 | + console.info(controlador); | |
| 285 | + var resolveFake = { data: { id: true } }; | |
| 286 | + var promesaChoferPorDni = Promise.resolve(resolveFake); | |
| 287 | + | |
| 288 | + //act | |
| 289 | + spyOn(focaAbmChoferService, 'getChoferPorDni').and.returnValue(promesaChoferPorDni); | |
| 290 | + spyOn(focaModalService, 'alert'); | |
| 291 | + scope.chofer.id = 'dato prueba'; | |
| 292 | + scope.guardar(13); | |
| 293 | + | |
| 294 | + //assert | |
| 295 | + promesaChoferPorDni.then(function() { | |
| 296 | + //await sleep(100); | |
| 297 | + setTimeout(function() { | |
| 298 | + expect(focaModalService.alert).toHaveBeenCalled(); | |
| 299 | + done(); | |
| 300 | + }); | |
| 301 | + }); | |
| 302 | + }); | |
| 303 | + }); | |
| 304 | +}); | 
spec/routeSpec.js
| ... | ... | @@ -0,0 +1,27 @@ | 
| 1 | +describe('Rutas abm chofer', function() { | |
| 2 | + | |
| 3 | + var route; | |
| 4 | + | |
| 5 | + beforeEach(function() { | |
| 6 | + module('focaAbmChofer'); | |
| 7 | + inject(function($route) { | |
| 8 | + route = $route; | |
| 9 | + }); | |
| 10 | + }); | |
| 11 | + | |
| 12 | + it('ruta /chofer redirecciona correctamente', function() { | |
| 13 | + //assert | |
| 14 | + expect(route.routes['/chofer'].controller) | |
| 15 | + .toBe('focaAbmChoferesController'); | |
| 16 | + expect(route.routes['/chofer'].templateUrl) | |
| 17 | + .toBe('src/views/foca-abm-choferes-listado.html'); | |
| 18 | + }); | |
| 19 | + | |
| 20 | + it('ruta /chofer/:id/:idTransportista redirecciona correctamente', function() { | |
| 21 | + //assert | |
| 22 | + expect(route.routes['/chofer/:id/:idTransportista'].controller) | |
| 23 | + .toBe('focaAbmChoferController'); | |
| 24 | + expect(route.routes['/chofer/:id/:idTransportista'].templateUrl) | |
| 25 | + .toBe('src/views/foca-abm-choferes-item.html'); | |
| 26 | + }); | |
| 27 | +}); | 
spec/serviceSpec.js
| ... | ... | @@ -0,0 +1,175 @@ | 
| 1 | +describe('Servicios de foca abm chofer', function() { | |
| 2 | + | |
| 3 | + var httpBackend; | |
| 4 | + var servicio; | |
| 5 | + | |
| 6 | + beforeEach(function() { | |
| 7 | + module('focaAbmChofer'); | |
| 8 | + inject(module(function($provide) { | |
| 9 | + $provide.value('API_ENDPOINT', { | |
| 10 | + URL: 'localhost' | |
| 11 | + }); | |
| 12 | + })); | |
| 13 | + inject(function($httpBackend, _focaAbmChoferService_) { | |
| 14 | + servicio = _focaAbmChoferService_; | |
| 15 | + httpBackend = $httpBackend; | |
| 16 | + }); | |
| 17 | + }); | |
| 18 | + | |
| 19 | + describe('Servicio focaAbmChoferService', function() { | |
| 20 | + it('Existe el servicio', function() { | |
| 21 | + //assert | |
| 22 | + expect(typeof servicio).toEqual('object'); | |
| 23 | + }); | |
| 24 | + | |
| 25 | + it('La función getChoferes lleva a la ruta correcta', function() { | |
| 26 | + //arrange | |
| 27 | + var returnFake = 'test'; | |
| 28 | + var result; | |
| 29 | + httpBackend.expectGET('localhost/chofer').respond(returnFake); | |
| 30 | + | |
| 31 | + //act | |
| 32 | + servicio.getChoferes().then(function(data) { | |
| 33 | + result = data.data; | |
| 34 | + }); | |
| 35 | + httpBackend.flush(); | |
| 36 | + | |
| 37 | + expect(result).toEqual(returnFake); | |
| 38 | + }); | |
| 39 | + | |
| 40 | + it('La función getChofer lleva a la ruta correcta', function() { | |
| 41 | + //arrange | |
| 42 | + var returnFake = 'test'; | |
| 43 | + var paramFake = 1; | |
| 44 | + var result; | |
| 45 | + httpBackend.expectGET('localhost/chofer/' + paramFake).respond(returnFake); | |
| 46 | + | |
| 47 | + //act | |
| 48 | + servicio.getChofer(paramFake).then(function(data) { | |
| 49 | + result = data.data; | |
| 50 | + }); | |
| 51 | + httpBackend.flush(); | |
| 52 | + | |
| 53 | + expect(result).toEqual(returnFake); | |
| 54 | + }); | |
| 55 | + | |
| 56 | + it('La función getChoferPorTransportista lleva a la ruta correcta', function() { | |
| 57 | + //arrange | |
| 58 | + var returnFake = 'test'; | |
| 59 | + var paramFake = 1; | |
| 60 | + var result; | |
| 61 | + httpBackend.expectGET('localhost/chofer/transportista/' + paramFake) | |
| 62 | + .respond(returnFake); | |
| 63 | + | |
| 64 | + //act | |
| 65 | + servicio.getChoferPorTransportista(paramFake).then(function(data) { | |
| 66 | + result = data.data; | |
| 67 | + }); | |
| 68 | + httpBackend.flush(); | |
| 69 | + | |
| 70 | + expect(result).toEqual(returnFake); | |
| 71 | + }); | |
| 72 | + | |
| 73 | + it('La función getChoferPorDni lleva a la ruta correcta', function() { | |
| 74 | + //arrange | |
| 75 | + var returnFake = 'test'; | |
| 76 | + var paramFake = 1; | |
| 77 | + var result; | |
| 78 | + httpBackend.expectPOST('localhost/chofer/dni', { dni: paramFake }) | |
| 79 | + .respond(returnFake); | |
| 80 | + | |
| 81 | + //act | |
| 82 | + servicio.getChoferPorDni(paramFake).then(function(data) { | |
| 83 | + result = data.data; | |
| 84 | + }); | |
| 85 | + httpBackend.flush(); | |
| 86 | + | |
| 87 | + //assert | |
| 88 | + expect(result).toEqual(returnFake); | |
| 89 | + }); | |
| 90 | + | |
| 91 | + it('La función guardarChofer llama a la ruta correcta', function() { | |
| 92 | + //arrange | |
| 93 | + var returnFake = 'test'; | |
| 94 | + var paramFake = 1; | |
| 95 | + var result; | |
| 96 | + httpBackend.expectPOST('localhost/chofer', { chofer: paramFake }) | |
| 97 | + .respond(returnFake); | |
| 98 | + | |
| 99 | + //act | |
| 100 | + servicio.guardarChofer(paramFake).then(function(data) { | |
| 101 | + result = data.data; | |
| 102 | + }); | |
| 103 | + httpBackend.flush(); | |
| 104 | + | |
| 105 | + //assert | |
| 106 | + expect(result).toEqual(returnFake); | |
| 107 | + }); | |
| 108 | + | |
| 109 | + it('La función getTransportistas lleva a la ruta correcta', function() { | |
| 110 | + //arrange | |
| 111 | + var returnFake = 'test'; | |
| 112 | + var result; | |
| 113 | + httpBackend.expectGET('localhost/transportista').respond(returnFake); | |
| 114 | + | |
| 115 | + //act | |
| 116 | + servicio.getTransportistas().then(function(data) { | |
| 117 | + result = data.data; | |
| 118 | + }); | |
| 119 | + httpBackend.flush(); | |
| 120 | + | |
| 121 | + //assert | |
| 122 | + expect(result).toEqual(returnFake); | |
| 123 | + }); | |
| 124 | + | |
| 125 | + it('La función getTransportistaPorId lleva a la ruta correcta', function() { | |
| 126 | + //arrange | |
| 127 | + var returnFake = 'test'; | |
| 128 | + var paramFake = 1; | |
| 129 | + var result; | |
| 130 | + httpBackend.expectGET('localhost/transportista/' + paramFake).respond(returnFake); | |
| 131 | + | |
| 132 | + //act | |
| 133 | + servicio.getTransportistaPorId(paramFake).then(function(data) { | |
| 134 | + result = data.data; | |
| 135 | + }); | |
| 136 | + httpBackend.flush(); | |
| 137 | + | |
| 138 | + //assert | |
| 139 | + expect(result).toEqual(returnFake); | |
| 140 | + }); | |
| 141 | + | |
| 142 | + it('La función deleteChofer lleva a la ruta correcta', function() { | |
| 143 | + //arrange | |
| 144 | + var returnFake = 'test'; | |
| 145 | + var paramFake = 1; | |
| 146 | + var result; | |
| 147 | + httpBackend.expectDELETE('localhost/chofer/' + paramFake).respond(returnFake); | |
| 148 | + | |
| 149 | + //act | |
| 150 | + servicio.deleteChofer(paramFake).then(function(data) { | |
| 151 | + result = data.data; | |
| 152 | + }); | |
| 153 | + httpBackend.flush(); | |
| 154 | + | |
| 155 | + //assert | |
| 156 | + expect(result).toEqual(returnFake); | |
| 157 | + }); | |
| 158 | + | |
| 159 | + it('La función getTiposDocumento lleva a la ruta correcta', function() { | |
| 160 | + //arrange | |
| 161 | + var returnFake = 'test'; | |
| 162 | + var result; | |
| 163 | + httpBackend.expectGET('localhost/tipo-documento').respond(returnFake); | |
| 164 | + | |
| 165 | + //act | |
| 166 | + servicio.getTiposDocumento().then(function(data) { | |
| 167 | + result = data.data; | |
| 168 | + }); | |
| 169 | + httpBackend.flush(); | |
| 170 | + | |
| 171 | + //assert | |
| 172 | + expect(result).toEqual(returnFake); | |
| 173 | + }); | |
| 174 | + }); | |
| 175 | +}); | 
src/js/app.js
test.html
| ... | ... | @@ -0,0 +1,21 @@ | 
| 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> |