2021-01-29 10:45:35 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Travel Component vnTravelSearchPanel', () => {
|
|
|
|
let controller;
|
|
|
|
|
|
|
|
beforeEach(ngModule('travel'));
|
|
|
|
|
|
|
|
beforeEach(inject($componentController => {
|
|
|
|
controller = $componentController('vnTravelSearchPanel', {$element: null});
|
|
|
|
controller.$t = () => {};
|
|
|
|
}));
|
|
|
|
|
2023-03-24 07:25:37 +00:00
|
|
|
describe('applyFilters()', () => {
|
|
|
|
it('should apply filters', async() => {
|
|
|
|
controller.filter = {foo: 'bar'};
|
|
|
|
controller.model = {
|
|
|
|
applyFilter: jest.fn().mockResolvedValue(),
|
|
|
|
_orgData: [{id: 1}]
|
|
|
|
};
|
|
|
|
controller.$state = {
|
|
|
|
current: {
|
|
|
|
name: 'foo'
|
|
|
|
},
|
|
|
|
go: jest.fn()
|
|
|
|
};
|
|
|
|
|
|
|
|
await controller.applyFilters(true);
|
|
|
|
|
|
|
|
expect(controller.model.applyFilter).toHaveBeenCalledWith({}, controller.filter);
|
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('travel.card.summary', {id: 1});
|
|
|
|
|
|
|
|
await controller.applyFilters(false);
|
|
|
|
|
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith(controller.$state.current.name,
|
|
|
|
{q: JSON.stringify(controller.filter)}, {location: 'replace'});
|
2021-01-29 10:45:35 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|