This commit is contained in:
Vicente Falco 2017-08-30 14:11:29 +02:00
commit ef2e80cbad
1 changed files with 23 additions and 1 deletions

View File

@ -11,9 +11,12 @@ describe('Component vnClientBillingData', () => {
beforeEach(angular.mock.inject(function(_$componentController_, $rootScope) {
$componentController = _$componentController_;
$scope = $rootScope.$new();
// try to instanciate the actual watcher instead of submit spy usage.
// should add instanciate of actual watcher instead of submit() spy usage.
let submit = jasmine.createSpy('submit').and.returnValue(Promise.resolve());
// should add instanciate of actual sendMail instead of show() spy usage.
let show = jasmine.createSpy('show');
$scope.watcher = {submit};
$scope.sendMail = {show};
}));
describe('copyData()', () => {
@ -45,4 +48,23 @@ describe('Component vnClientBillingData', () => {
});
});
});
describe('checkPaymentChanges()', () => {
it(`should not call sendMail.show() if there are no changes on billing data`, () => {
let controller = $componentController('vnClientBillingData', {$scope: $scope});
controller.billData = {marvelHero: 'Silver Surfer'};
controller.client = {marvelHero: 'Silver Surfer'};
controller.checkPaymentChanges();
expect(controller.$.sendMail.show).not.toHaveBeenCalled();
});
it(`should call sendMail.show() if there are changes on billing data`, () => {
let controller = $componentController('vnClientBillingData', {$scope: $scope});
controller.billData = {marvelHero: 'Silver Surfer'};
controller.client = {marvelHero: 'Spider-Man'};
controller.checkPaymentChanges();
expect(controller.$.sendMail.show).toHaveBeenCalled();
});
});
});