2019-10-25 11:26:38 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Travel Component vnTravelBasicData', () => {
|
|
|
|
let controller;
|
2020-03-18 11:55:22 +00:00
|
|
|
|
2019-10-25 11:26:38 +00:00
|
|
|
beforeEach(angular.mock.module('travel', $translateProvider => {
|
|
|
|
$translateProvider.translations('en', {});
|
|
|
|
}));
|
|
|
|
|
2020-03-18 11:55:22 +00:00
|
|
|
beforeEach(angular.mock.inject($componentController => {
|
|
|
|
const $element = angular.element('<vn-travel-basic-data></vn-travel-basic-data>');
|
|
|
|
controller = $componentController('vnTravelBasicData', {$element});
|
2019-10-25 11:26:38 +00:00
|
|
|
controller.card = {reload: () => {}};
|
|
|
|
controller.$.watcher = {submit: () => {}};
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('onSubmit()', () => {
|
|
|
|
it('should call the card reload method after the watcher submits', done => {
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn(controller.card, 'reload');
|
|
|
|
jest.spyOn(controller.$.watcher, 'submit').mockReturnValue(Promise.resolve());
|
2019-10-25 11:26:38 +00:00
|
|
|
|
|
|
|
controller.onSubmit().then(() => {
|
|
|
|
expect(controller.card.reload).toHaveBeenCalledWith();
|
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|