From d02c79d2e8a963a9700308fa46fbc5c9576701b5 Mon Sep 17 00:00:00 2001 From: Bernat Date: Fri, 25 Oct 2019 13:29:05 +0200 Subject: [PATCH] #1774 travel.index test and refactor --- modules/agency/front/index/index.spec.js | 2 +- modules/route/front/basic-data/index.html | 10 +++---- modules/route/front/basic-data/index.js | 9 ++++--- modules/travel/front/index/index.html | 4 +-- modules/travel/front/index/index.js | 2 +- modules/travel/front/index/index.spec.js | 33 +++++++++++++++++++++++ 6 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 modules/travel/front/index/index.spec.js diff --git a/modules/agency/front/index/index.spec.js b/modules/agency/front/index/index.spec.js index c4ffb975e..6ffdf3170 100644 --- a/modules/agency/front/index/index.spec.js +++ b/modules/agency/front/index/index.spec.js @@ -22,7 +22,7 @@ describe('Agency Component vnZoneIndex', () => { expect(result).toEqual({id: 1}); }); - it('should return a formated object with the warehouseFk in case of agencyModeFk', () => { + it('should return a formated object with the agencyModeFk in case of agencyModeFk', () => { let param = 'agencyModeFk'; let value = 'My Delivery'; let result = controller.exprBuilder(param, value); diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html index daad13a56..67accfff5 100644 --- a/modules/route/front/basic-data/index.html +++ b/modules/route/front/basic-data/index.html @@ -1,4 +1,4 @@ - + @@ -36,7 +36,7 @@ @@ -73,7 +73,7 @@ ng-model="$ctrl.route.description" rule vn-focus> - + diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js index 3c64200f4..810fd7511 100644 --- a/modules/route/front/basic-data/index.js +++ b/modules/route/front/basic-data/index.js @@ -1,17 +1,18 @@ import ngModule from '../module'; class Controller { - constructor($scope, $state) { - this.$scope = $scope; - this.$state = $state; + constructor($scope) { + this.$ = $scope; } onSubmit() { - this.$scope.watcher.submit().then(() => { + this.$.watcher.submit().then(() => { this.card.reload(); }); } } +Controller.$inject = ['$scope']; + ngModule.component('vnRouteBasicData', { template: require('./index.html'), controller: Controller, diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index 6af3ddad0..3534fd0bd 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -41,10 +41,10 @@ {{::travel.id}} {{::travel.ref}} {{::travel.agency.name}} - {{::travel.warehouseOut.name}} + {{::travel.warehouseOut.name}} {{::travel.shipped | date:'dd/MM/yyyy'}} - {{::travel.warehouseIn.name}} + {{::travel.warehouseIn.name}} {{::travel.landed | date:'dd/MM/yyyy'}} diff --git a/modules/travel/front/index/index.js b/modules/travel/front/index/index.js index 068569c0b..b080ed8ec 100644 --- a/modules/travel/front/index/index.js +++ b/modules/travel/front/index/index.js @@ -40,7 +40,7 @@ export default class Controller { case 'landed': return {landed: {gte: value}}; case 'id': - case 'agencyFk': + case 'agencyModeFk': case 'warehouseOutFk': case 'warehouseInFk': case 'totalEntries': diff --git a/modules/travel/front/index/index.spec.js b/modules/travel/front/index/index.spec.js new file mode 100644 index 000000000..321109003 --- /dev/null +++ b/modules/travel/front/index/index.spec.js @@ -0,0 +1,33 @@ +import './index.js'; + +describe('Travel Component vnTravelIndex', () => { + let $componentController; + let controller; + + beforeEach(angular.mock.module('travel', $translateProvider => { + $translateProvider.translations('en', {}); + })); + + beforeEach(angular.mock.inject(_$componentController_ => { + $componentController = _$componentController_; + controller = $componentController('vnTravelIndex'); + })); + + describe('exprBuilder()', () => { + it('should return a formated object with the travel id in case of search', () => { + let param = 'search'; + let value = 2; + let result = controller.exprBuilder(param, value); + + expect(result).toEqual({id: 2}); + }); + + it('should return a formated object with the warehouseInFk in case of warehouseInFk', () => { + let param = 'warehouseInFk'; + let value = 3; + let result = controller.exprBuilder(param, value); + + expect(result).toEqual({warehouseInFk: 3}); + }); + }); +});