43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Route', () => {
|
|
describe('Component vnZoneCard', () => {
|
|
let $componentController;
|
|
let $scope;
|
|
let controller;
|
|
let $httpBackend;
|
|
let $stateParams;
|
|
|
|
beforeEach(() => {
|
|
angular.mock.module('route');
|
|
});
|
|
|
|
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(`/route/api/Zones/1?filter=${json}`).respond({id: 1});
|
|
controller.getCard();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.zone).toEqual({id: 1});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|