2018-05-23 12:26:51 +00:00
|
|
|
import './index';
|
2017-08-31 06:53:17 +00:00
|
|
|
|
2017-09-04 13:06:43 +00:00
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnAddressEdit', () => {
|
|
|
|
let $componentController;
|
|
|
|
let $state;
|
2017-10-17 12:24:40 +00:00
|
|
|
let controller;
|
2018-02-05 09:58:49 +00:00
|
|
|
let $httpBackend;
|
2017-08-31 06:53:17 +00:00
|
|
|
|
2017-09-04 13:06:43 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
angular.mock.module('client');
|
|
|
|
});
|
2017-08-31 06:53:17 +00:00
|
|
|
|
2018-02-05 09:58:49 +00:00
|
|
|
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
|
2017-09-04 13:06:43 +00:00
|
|
|
$componentController = _$componentController_;
|
|
|
|
$state = _$state_;
|
2018-02-05 09:58:49 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2018-02-06 14:09:31 +00:00
|
|
|
$state.params.addressId = '1';
|
2017-10-17 12:24:40 +00:00
|
|
|
controller = $componentController('vnAddressEdit', {$state: $state});
|
2017-09-04 13:06:43 +00:00
|
|
|
}));
|
2017-08-31 06:53:17 +00:00
|
|
|
|
2017-09-04 13:06:43 +00:00
|
|
|
it('should define and set address property', () => {
|
2018-02-07 13:47:08 +00:00
|
|
|
expect(controller.address.id).toEqual(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('_observationsEquals', () => {
|
|
|
|
it('should return true if two observations are equals independent of control attributes', () => {
|
|
|
|
let ob1 = {id: 1, observationTypeFk: 1, description: 'Spiderman rocks', showAddIcon: true};
|
|
|
|
let ob2 = {id: 1, observationTypeFk: 1, description: 'Spiderman rocks', showAddIcon: false};
|
2018-04-06 16:40:24 +00:00
|
|
|
let equals = controller.equalObservations(ob2, ob1);
|
2018-02-07 13:47:08 +00:00
|
|
|
|
|
|
|
expect(equals).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return false if two observations are not equals independent of control attributes', () => {
|
|
|
|
let ob1 = {id: 1, observationTypeFk: 1, description: 'Spiderman rocks', showAddIcon: true};
|
|
|
|
let ob2 = {id: 1, observationTypeFk: 1, description: 'Spiderman sucks', showAddIcon: true};
|
2018-04-06 16:40:24 +00:00
|
|
|
let equals = controller.equalObservations(ob2, ob1);
|
2018-02-07 13:47:08 +00:00
|
|
|
|
|
|
|
expect(equals).toBeFalsy();
|
|
|
|
});
|
2017-09-04 13:06:43 +00:00
|
|
|
});
|
2018-02-05 09:58:49 +00:00
|
|
|
|
|
|
|
describe('$onInit()', () => {
|
|
|
|
it('should perform a GET query to receive the address observations', () => {
|
2018-02-06 14:09:31 +00:00
|
|
|
let filter = {where: {addressFk: 1}, include: {relation: 'observationType'}};
|
|
|
|
let res = ['some notes'];
|
2018-04-06 16:40:24 +00:00
|
|
|
$httpBackend.whenGET(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).respond(res);
|
2018-02-05 09:58:49 +00:00
|
|
|
$httpBackend.expectGET(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`);
|
|
|
|
controller.$onInit();
|
|
|
|
$httpBackend.flush();
|
|
|
|
});
|
|
|
|
});
|
2017-08-31 06:53:17 +00:00
|
|
|
});
|
|
|
|
});
|