test front worker.phone
gitea/salix/1858testworkerPhone This commit looks good
Details
gitea/salix/1858testworkerPhone This commit looks good
Details
This commit is contained in:
parent
8a2eda7c08
commit
a87ce44f08
|
@ -24,7 +24,7 @@ class Controller {
|
|||
|
||||
onSubmit() {
|
||||
this.$scope.watcher.check();
|
||||
this.$scope.model.save().then(() => {
|
||||
return this.$scope.model.save().then(() => {
|
||||
this.$scope.watcher.updateOriginalData();
|
||||
this.$scope.watcher.notifySaved();
|
||||
this.card.reload();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import './index';
|
||||
import watcher from 'core/mocks/watcher';
|
||||
|
||||
describe('Component vnWorkerPhones', () => {
|
||||
let controller;
|
||||
|
@ -8,8 +9,12 @@ describe('Component vnWorkerPhones', () => {
|
|||
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
|
||||
let $scope = $rootScope.$new();
|
||||
controller = $componentController('vnWorkerPhones', $scope);
|
||||
controller.$scope.model = {link: 1};
|
||||
controller.$scope.$applyAsync = () => {};
|
||||
controller.$scope.watcher = watcher;
|
||||
controller.$scope.model = {
|
||||
link: 1,
|
||||
save: () => {}
|
||||
};
|
||||
controller.card = {reload: () => {}};
|
||||
}));
|
||||
|
||||
describe('setLink()', () => {
|
||||
|
@ -21,4 +26,22 @@ describe('Component vnWorkerPhones', () => {
|
|||
expect(controller.$scope.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
||||
});
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should call watcher functions, reload the card and save the model', done => {
|
||||
spyOn(controller.$scope.watcher, 'check');
|
||||
spyOn(controller.$scope.model, 'save').and.returnValue(Promise.resolve());
|
||||
|
||||
spyOn(controller.$scope.watcher, 'updateOriginalData');
|
||||
spyOn(controller.$scope.watcher, 'notifySaved');
|
||||
spyOn(controller.card, 'reload');
|
||||
controller.onSubmit();
|
||||
controller.onSubmit().then(() => {
|
||||
expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
||||
expect(controller.$scope.watcher.notifySaved).toHaveBeenCalledWith();
|
||||
expect(controller.card.reload).toHaveBeenCalledWith();
|
||||
done();
|
||||
}).catch(done.fail);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue