salix/client/client/src/address/edit/address-edit.spec.js

56 lines
2.3 KiB
JavaScript
Raw Normal View History

2018-05-23 12:26:51 +00:00
import './index';
describe('Client', () => {
describe('Component vnAddressEdit', () => {
let $componentController;
let $state;
let controller;
let $httpBackend;
beforeEach(() => {
angular.mock.module('client');
});
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
$componentController = _$componentController_;
$state = _$state_;
$httpBackend = _$httpBackend_;
2018-02-06 14:09:31 +00:00
$state.params.addressId = '1';
controller = $componentController('vnAddressEdit', {$state: $state});
}));
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};
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};
let equals = controller.equalObservations(ob2, ob1);
2018-02-07 13:47:08 +00:00
expect(equals).toBeFalsy();
});
});
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'];
$httpBackend.whenGET(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).respond(res);
$httpBackend.expectGET(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`);
controller.$onInit();
$httpBackend.flush();
});
});
});
});