import './index.js'; describe('Agency', () => { describe('Component vnZoneCard', () => { let $componentController; let $scope; let controller; let $httpBackend; let $stateParams; beforeEach(() => { angular.mock.module('agency'); }); beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { $componentController = _$componentController_; $httpBackend = _$httpBackend_; $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); $scope = $rootScope.$new(); $stateParams = {id: 1}; controller = $componentController('vnZoneCard', {$scope: $scope, $stateParams}); })); describe('getCard()', () => { it(`should make a query and define zone property`, () => { let filter = { include: [ {relation: 'warehouse', fields: ['name']}, {relation: 'agencyMode', fields: ['name']} ] }; let json = encodeURIComponent(JSON.stringify(filter)); $httpBackend.expectGET(`/agency/api/Zones/1?filter=${json}`).respond({id: 1}); controller.getCard(); $httpBackend.flush(); expect(controller.zone).toEqual({id: 1}); }); }); }); });