front unit tests for address-edit, fiscal-data and removed spec file for search-panel as theres nothing to test anymore

This commit is contained in:
Carlos Jimenez 2018-02-05 10:58:49 +01:00
parent 89c745244a
commit 1a1f861205
5 changed files with 54 additions and 51 deletions

View File

@ -5,14 +5,16 @@ describe('Client', () => {
let $componentController;
let $state;
let controller;
let $httpBackend;
beforeEach(() => {
angular.mock.module('client');
});
beforeEach(angular.mock.inject((_$componentController_, _$state_) => {
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
$componentController = _$componentController_;
$state = _$state_;
$httpBackend = _$httpBackend_;
$state.params.addressId = '1234';
controller = $componentController('vnAddressEdit', {$state: $state});
}));
@ -20,5 +22,16 @@ describe('Client', () => {
it('should define and set address property', () => {
expect(controller.address.id).toBe(1234);
});
describe('$onInit()', () => {
it('should perform a GET query to receive the address observations', () => {
let filter = {where: {addressFk: 1234}, include: [{relation: 'observationType'}]};
let json = {data: 'some notes'};
$httpBackend.when('GET', `/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).respond(json);
$httpBackend.expectGET(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`);
controller.$onInit();
$httpBackend.flush();
});
});
});
});

View File

@ -0,0 +1,31 @@
import './fiscal-data.js';
describe('Client', () => {
describe('Component vnClientFiscalData', () => {
let $componentController;
let $httpBackend;
let $scope;
let controller;
beforeEach(() => {
angular.mock.module('client');
});
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
controller = $componentController('vnClientFiscalData', {$scope: $scope});
}));
describe('returnDialogEt()', () => {
it('should request to patch the propagation of tax status', () => {
controller.client = {id: 123, isEqualizated: false};
$httpBackend.when('PATCH', `/client/api/Clients/${controller.client.id}/addressesPropagateRe`, {isEqualizated: controller.client.isEqualizated}).respond('done');
$httpBackend.expectPATCH(`/client/api/Clients/${controller.client.id}/addressesPropagateRe`, {isEqualizated: controller.client.isEqualizated});
controller.returnDialogEt('ACCEPT');
$httpBackend.flush();
});
});
});
});

View File

@ -1,41 +0,0 @@
import './search-panel.js';
describe('Client', () => {
describe('Component vnClientSearchPanel', () => {
let $componentController;
let sessionStorage;
let controller;
beforeEach(() => {
angular.mock.module('client');
});
beforeEach(angular.mock.inject((_$componentController_, _sessionStorage_) => {
$componentController = _$componentController_;
sessionStorage = _sessionStorage_;
controller = $componentController('vnClientSearchPanel', {sessionStorage: sessionStorage});
}));
// describe('onSearch()', () => {
// it('should call setStorageValue() and onSubmit()', () => {
// spyOn(controller, 'setStorageValue');
// spyOn(controller, 'onSubmit');
// controller.setStorageValue();
// controller.onSubmit();
// expect(controller.setStorageValue).toHaveBeenCalledWith();
// expect(controller.onSubmit).toHaveBeenCalledWith();
// });
// });
// describe('$onChanges()', () => {
// it('should set filter properties using the search values', () => {
// expect(controller.filter).not.toBeDefined();
// spyOn(sessionStorage, 'get').and.returnValue({data: 'data'});
// controller.$onChanges();
// expect(controller.filter).toBe(sessionStorage.get({data: 'data'}));
// });
// });
});
});

14
package-lock.json generated
View File

@ -113,7 +113,7 @@
"angular": {
"version": "1.6.8",
"resolved": "https://registry.npmjs.org/angular/-/angular-1.6.8.tgz",
"integrity": "sha512-9WErZIOw1Cu1V5Yxdvxz/6YpND8ntdP71fdPpufPFJvZodZXqCjQBYrHqEoMZreO5i84O3D/Jw/vepoFt68Azw=="
"integrity": "sha1-W+N4pYvpGlSJ54tZxFGM2f0nP/s="
},
"angular-cookies": {
"version": "1.6.4",
@ -1119,7 +1119,7 @@
"bluebird": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==",
"integrity": "sha1-2VUfnemPH82h5oPRfukaBgLuLrk=",
"dev": true
},
"bn.js": {
@ -5328,7 +5328,7 @@
"fsevents": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz",
"integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==",
"integrity": "sha1-EfgjGPX+e7LNIpZaEI6TBiCCFtg=",
"dev": true,
"optional": true,
"requires": {
@ -9909,7 +9909,7 @@
"jasmine-spec-reporter": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz",
"integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==",
"integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=",
"dev": true,
"requires": {
"colors": "1.1.2"
@ -10051,7 +10051,7 @@
"karma": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz",
"integrity": "sha512-k5pBjHDhmkdaUccnC7gE3mBzZjcxyxYsYVaqiL2G5AqlfLyBO5nw2VdNK+O16cveEPd/gIOWULH7gkiYYwVNHg==",
"integrity": "sha1-hcwI6eCiLXzpzKN8ShvoJPaisa4=",
"dev": true,
"requires": {
"bluebird": "3.5.1",
@ -10113,7 +10113,7 @@
"karma-firefox-launcher": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.1.0.tgz",
"integrity": "sha512-LbZ5/XlIXLeQ3cqnCbYLn+rOVhuMIK9aZwlP6eOLGzWdo1UVp7t6CN3DP4SafiRLjexKwHeKHDm0c38Mtd3VxA==",
"integrity": "sha1-LEcDBFLwRTHrfRPU/HZpYwu5Mzk=",
"dev": true
},
"karma-jasmine": {
@ -14654,7 +14654,7 @@
"useragent": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz",
"integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==",
"integrity": "sha1-IX+UOtVAyyEoZYqyP8lg9qiMmXI=",
"dev": true,
"requires": {
"lru-cache": "4.1.1",

View File

@ -18,8 +18,8 @@ jasmine.loadConfig({
spec_dir: 'services',
spec_files: [
'auth/server/**/*[sS]pec.js',
'loopback/common/**/*[sS]pec.js',
'client/common/**/*[sS]pec.js'
'client/common/**/*[sS]pec.js',
'loopback/common/**/*[sS]pec.js'
],
helpers: [
'/services/utils/jasmineHelpers.js'