salix/modules/agency/front/card/index.spec.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-09-19 13:05:07 +00:00
import './index.js';
2019-04-26 14:10:51 +00:00
describe('Agency Component vnZoneCard', () => {
let $scope;
let controller;
let $httpBackend;
let $stateParams;
2018-09-19 13:05:07 +00:00
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.module('agency', $translateProvider => {
$translateProvider.translations('en', {});
}));
2018-09-19 13:05:07 +00:00
2019-04-26 14:10:51 +00:00
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
$stateParams = {id: 1};
controller = $componentController('vnZoneCard', {$scope, $stateParams});
}));
2018-09-19 13:05:07 +00:00
2019-04-26 14:10:51 +00:00
describe('getCard()', () => {
it(`should make a query and define zone property`, () => {
let filter = {
2019-09-26 12:51:45 +00:00
include: {
relation: 'agencyMode',
scope: {fields: ['name']}
}
2019-04-26 14:10:51 +00:00
};
let json = encodeURIComponent(JSON.stringify(filter));
$httpBackend.expectGET(`/agency/api/Zones/1?filter=${json}`).respond({id: 1});
controller.getCard();
$httpBackend.flush();
2018-09-19 13:05:07 +00:00
2019-04-26 14:10:51 +00:00
expect(controller.zone).toEqual({id: 1});
2018-09-19 13:05:07 +00:00
});
});
});