Commit 0fdf7f0a11d5bfe0d41c1d2967ba0e3ce49fb7be
Exists in
master
and in
2 other branches
Merge branch 'master' into 'master'
Master(efernandez) See merge request !11
Showing
7 changed files
Show diff stats
gulpfile.js
1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
2 | const concat = require('gulp-concat'); | 2 | const concat = require('gulp-concat'); |
3 | const htmlmin = require('gulp-htmlmin'); | 3 | const htmlmin = require('gulp-htmlmin'); |
4 | const rename = require('gulp-rename'); | 4 | const rename = require('gulp-rename'); |
5 | const uglify = require('gulp-uglify-es').default; | 5 | const uglify = require('gulp-uglify-es').default; |
6 | const gulp = require('gulp'); | 6 | const gulp = require('gulp'); |
7 | const pump = require('pump'); | 7 | const pump = require('pump'); |
8 | const jshint = require('gulp-jshint'); | 8 | const jshint = require('gulp-jshint'); |
9 | const replace = require('gulp-replace'); | 9 | const replace = require('gulp-replace'); |
10 | const connect = require('gulp-connect'); | 10 | const connect = require('gulp-connect'); |
11 | const clean = require('gulp-clean'); | 11 | const clean = require('gulp-clean'); |
12 | const header = require('gulp-header'); | ||
13 | const footer =require('gulp-footer'); | ||
12 | 14 | ||
13 | var paths = { | 15 | var paths = { |
14 | srcJS: 'src/js/*.js', | 16 | srcJS: 'src/js/*.js', |
15 | srcViews: 'src/views/*.html', | 17 | srcViews: 'src/views/*.html', |
18 | specs: 'spec/*.js', | ||
16 | tmp: 'tmp', | 19 | tmp: 'tmp', |
17 | dist: 'dist/' | 20 | dist: 'dist/' |
18 | }; | 21 | }; |
19 | 22 | ||
20 | gulp.task('templates', function() { | 23 | gulp.task('templates', function() { |
21 | return pump( | 24 | return pump( |
22 | [ | 25 | [ |
23 | gulp.src(paths.srcViews), | 26 | gulp.src(paths.srcViews), |
24 | replace('views/', ''), | 27 | replace('views/', ''), |
25 | htmlmin(), | 28 | htmlmin(), |
26 | templateCache('views.js', { | 29 | templateCache('views.js', { |
27 | module: 'focaAbmChofer', | 30 | module: 'focaAbmChofer', |
28 | root: '' | 31 | root: '' |
29 | }), | 32 | }), |
30 | gulp.dest(paths.tmp) | 33 | gulp.dest(paths.tmp) |
31 | ] | 34 | ] |
32 | ); | 35 | ); |
33 | }); | 36 | }); |
34 | 37 | ||
35 | gulp.task('uglify', ['templates'], function() { | 38 | gulp.task('uglify', ['templates', 'uglify-spec'], function() { |
36 | return pump( | 39 | return pump( |
37 | [ | 40 | [ |
38 | gulp.src([ | 41 | gulp.src([ |
39 | paths.srcJS, | 42 | paths.srcJS, |
40 | 'tmp/views.js' | 43 | 'tmp/views.js' |
41 | ]), | 44 | ]), |
42 | concat('foca-abm-chofer.js'), | 45 | concat('foca-abm-chofer.js'), |
43 | replace("src/views/", ''), | 46 | replace("src/views/", ''), |
44 | gulp.dest(paths.tmp), | 47 | gulp.dest(paths.tmp), |
45 | rename('foca-abm-chofer.min.js'), | 48 | rename('foca-abm-chofer.min.js'), |
46 | uglify(), | 49 | uglify(), |
47 | gulp.dest(paths.dist) | 50 | gulp.dest(paths.dist) |
48 | ] | 51 | ] |
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 | gulp.task('clean', function() { | 66 | gulp.task('clean', function() { |
53 | return gulp.src(['tmp', 'dist'], {read: false}) | 67 | return gulp.src(['tmp', 'dist'], {read: false}) |
54 | .pipe(clean()); | 68 | .pipe(clean()); |
55 | }); | 69 | }); |
56 | 70 | ||
57 | gulp.task('pre-commit', function() { | 71 | gulp.task('pre-commit', function() { |
58 | pump( | 72 | pump( |
59 | [ | 73 | [ |
60 | gulp.src(paths.srcJS), | 74 | gulp.src([paths.srcJS, paths.specs]), |
61 | jshint('.jshintrc'), | 75 | jshint('.jshintrc'), |
62 | jshint.reporter('default'), | 76 | jshint.reporter('default'), |
63 | jshint.reporter('fail') | 77 | jshint.reporter('fail') |
64 | ] | 78 | ] |
65 | ); | 79 | ); |
66 | 80 | ||
67 | gulp.start('uglify'); | 81 | gulp.start('uglify'); |
68 | }); | 82 | }); |
69 | 83 | ||
70 | gulp.task('clean-post-install', function() { | 84 | gulp.task('clean-post-install', function() { |
71 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 85 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
72 | 'index.html'], {read: false}) | 86 | 'index.html', 'spec'], {read: false}) |
73 | .pipe(clean()); | 87 | .pipe(clean()); |
74 | }); | 88 | }); |
75 | 89 | ||
76 | gulp.task('compile', ['templates', 'uglify']); | 90 | gulp.task('compile', ['templates', 'uglify']); |
77 | 91 | ||
78 | gulp.task('watch', function() { | 92 | gulp.task('watch', function() { |
79 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 93 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
80 | }); | 94 | }); |
81 | 95 | ||
82 | gulp.task('webserver', function() { | 96 | gulp.task('webserver', function() { |
83 | pump [ | 97 | pump [ |
84 | connect.server({port: 3000}) | 98 | connect.server({port: 3000}) |
85 | ] | 99 | ] |
86 | }); | 100 | }); |
87 | 101 | ||
88 | gulp.task('default', ['webserver']); | 102 | gulp.task('default', ['webserver']); |
89 | 103 |
package.json
1 | { | 1 | { |
2 | "name": "foca-abm-chofer", | 2 | "name": "foca-abm-chofer", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "Abm de chofer", | 4 | "description": "Abm de chofer", |
5 | "main": "index.html", | 5 | "main": "index.html", |
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 angular bootstrap ui-bootstrap4 font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-uglify gulp-clean jshint pump git+http://git.focasoftware.com/npm/foca-modal.git" | 11 | "install-dev": "npm install -D angular bootstrap ui-bootstrap4 font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-uglify gulp-clean jshint pump git+http://git.focasoftware.com/npm/foca-modal.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-abm-chofer.git" | 18 | "url": "http://git.focasoftware.com/npm/foca-abm-chofer.git" |
19 | }, | 19 | }, |
20 | "author": "Foca Software", | 20 | "author": "Foca Software", |
21 | "license": "ISC", | 21 | "license": "ISC", |
22 | "peerDependencies": { | 22 | "peerDependencies": { |
23 | "angular": "^1.7.x", | 23 | "angular": "^1.7.x", |
24 | "angular-route": "^1.7.x", | 24 | "angular-route": "^1.7.x", |
25 | "bootstrap": "^4.1.x", | 25 | "bootstrap": "^4.1.x", |
26 | "jquery": "^3.3.x", | 26 | "jquery": "^3.3.x", |
27 | "font-awesome": "^4.7.x", | 27 | "font-awesome": "^4.7.x", |
28 | "gulp": "^3.9.x", | 28 | "gulp": "^3.9.x", |
29 | "gulp-concat": "2.6.x", | 29 | "gulp-concat": "2.6.x", |
30 | "gulp-jshint": "^2.1.x", | 30 | "gulp-jshint": "^2.1.x", |
31 | "gulp-rename": "^1.4.x", | 31 | "gulp-rename": "^1.4.x", |
32 | "gulp-replace": "^1.0.x", | 32 | "gulp-replace": "^1.0.x", |
33 | "gulp-uglify-es": "^1.0.x", | 33 | "gulp-uglify-es": "^1.0.x", |
34 | "jshint": "^2.9.x", | 34 | "jshint": "^2.9.x", |
35 | "pump": "^3.0.x" | 35 | "pump": "^3.0.x" |
36 | }, | 36 | }, |
37 | "devDependencies": { | 37 | "devDependencies": { |
38 | "angular": "^1.7.7", | 38 | "angular": "^1.7.7", |
39 | "angular-route": "^1.7.5", | 39 | "angular-mocks": "^1.7.7", |
40 | "angular-route": "^1.7.7", | ||
40 | "bootstrap": "^4.2.1", | 41 | "bootstrap": "^4.2.1", |
41 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 42 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
42 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 43 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
43 | "font-awesome": "^4.7.0", | 44 | "font-awesome": "^4.7.0", |
44 | "gulp": "^3.9.1", | 45 | "gulp": "^3.9.1", |
45 | "gulp-angular-templatecache": "^2.2.6", | 46 | "gulp-angular-templatecache": "^2.2.6", |
46 | "gulp-clean": "^0.4.0", | 47 | "gulp-clean": "^0.4.0", |
47 | "gulp-connect": "^5.7.0", | 48 | "gulp-connect": "^5.7.0", |
49 | "gulp-header": "^2.0.7", | ||
48 | "gulp-htmlmin": "^5.0.1", | 50 | "gulp-htmlmin": "^5.0.1", |
49 | "gulp-jshint": "^2.1.0", | 51 | "gulp-jshint": "^2.1.0", |
50 | "gulp-rename": "^1.4.0", | 52 | "gulp-rename": "^1.4.0", |
51 | "gulp-replace": "^1.0.0", | 53 | "gulp-replace": "^1.0.0", |
52 | "gulp-uglify": "^3.0.1", | 54 | "gulp-uglify": "^3.0.1", |
53 | "gulp-uglify-es": "^1.0.4", | 55 | "gulp-uglify-es": "^1.0.4", |
54 | "jasmine-core": "^3.3.0", | 56 | "jasmine-core": "^3.3.0", |
55 | "jquery": "^3.3.1", | 57 | "jquery": "^3.3.1", |
56 | "jshint": "^2.10.0", | 58 | "jshint": "^2.10.0", |
57 | "pre-commit": "^1.2.2", | 59 | "pre-commit": "^1.2.2", |
58 | "pump": "^3.0.0", | 60 | "pump": "^3.0.0", |
59 | "ui-bootstrap4": "^3.0.6" | 61 | "ui-bootstrap4": "^3.0.6" |
60 | } | 62 | } |
61 | } | 63 | } |
62 | 64 |
spec/controllerSpec.js
File was created | 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 | }); | ||
305 |
spec/routeSpec.js
File was created | 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 | }); | ||
28 |
spec/serviceSpec.js
File was created | 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 | }); | ||
176 |
src/js/app.js
1 | angular.module('focaAbmChofer', []); | 1 | angular.module('focaAbmChofer', ['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 |