salix/client/route/src/zone/card/index.spec.js

43 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-09-19 13:05:07 +00:00
import './index.js';
2018-09-21 10:35:54 +00:00
describe('Route', () => {
describe('Component vnZoneCard', () => {
2018-09-19 13:05:07 +00:00
let $componentController;
let $scope;
let controller;
let $httpBackend;
2018-09-21 10:35:54 +00:00
let $stateParams;
2018-09-19 13:05:07 +00:00
beforeEach(() => {
2018-09-21 10:35:54 +00:00
angular.mock.module('route');
2018-09-19 13:05:07 +00:00
});
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$scope = $rootScope.$new();
2018-09-21 10:35:54 +00:00
$stateParams = {id: 1};
controller = $componentController('vnZoneCard', {$scope: $scope, $stateParams});
2018-09-19 13:05:07 +00:00
}));
2018-09-21 10:35:54 +00:00
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();
2018-09-19 13:05:07 +00:00
$httpBackend.flush();
2018-09-21 10:35:54 +00:00
expect(controller.zone).toEqual({id: 1});
2018-09-19 13:05:07 +00:00
});
});
});
});