#1944 ticket.summary

This commit is contained in:
Carlos Jimenez Ruiz 2020-02-05 13:37:36 +01:00
parent 76fc5a3311
commit 06c3580bc4
2 changed files with 78 additions and 1 deletions

View File

@ -54,7 +54,7 @@ class Controller extends Component {
this.canceler = this.$q.defer();
let query = `Routes/findOne`;
let query = 'Routes/findOne';
let filter = {
fields: [

View File

@ -0,0 +1,77 @@
import './index';
describe('vnRouteDescriptorPopover', () => {
let $httpBackend;
let $scope;
let controller;
let $element;
let $timeout;
beforeEach(ngModule('route'));
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$timeout_) => {
$httpBackend = _$httpBackend_;
$timeout = _$timeout_;
$element = angular.element(`<div></div>`);
$scope = $rootScope.$new();
$scope.popover = {relocate: () => {}, show: () => {}};
controller = $componentController('vnRouteDescriptorPopover', {$scope, $element});
}));
describe('routeFk()', () => {
it(`should do nothing if the received id isn't a new one`, () => {
controller.route = 'I exist!';
controller._routeFk = 1;
spyOn(controller, 'getCard');
controller.routeFk = 1;
expect(controller.route).toEqual('I exist!');
expect(controller._routeFk).toEqual(1);
expect(controller.getCard).not.toHaveBeenCalled();
});
it(`should set the received id, set the route null and then call getCard()`, () => {
controller.route = `Please don't`;
controller._routeFk = 1;
spyOn(controller, 'getCard');
controller.routeFk = 999;
expect(controller.route).toBeNull();
expect(controller._routeFk).toEqual(999);
expect(controller.getCard).toHaveBeenCalledWith();
});
});
describe('route()', () => {
it(`should save the client on the controller and then call relocate()`, () => {
spyOn(controller.$.popover, 'relocate');
let route = `i'm the route!`;
controller.route = route;
$timeout.flush();
expect(controller.route).toEqual(route);
expect(controller.$.popover.relocate).toHaveBeenCalledWith();
});
});
describe('show()', () => {
it(`should call the popover show() mothod`, () => {
spyOn(controller.$.popover, 'show');
controller.show();
expect(controller.$.popover.show).toHaveBeenCalledWith();
});
});
describe('getCard()', () => {
it(`should perform a get query to store the client data into the controller`, () => {
let response = {the: 'route'};
$httpBackend.whenRoute('GET', 'Routes/findOne').respond(response);
controller.routeFk = 1;
$httpBackend.flush();
expect(controller.route).toEqual(response);
});
});
});