Skip to content

Instantly share code, notes, and snippets.

@qetr1ck-op
Created February 4, 2017 10:36
Show Gist options
  • Save qetr1ck-op/a6da1ed5ad345ad2085b06f75edcd528 to your computer and use it in GitHub Desktop.
Save qetr1ck-op/a6da1ed5ad345ad2085b06f75edcd528 to your computer and use it in GitHub Desktop.
import ContactCtrl from './contact.ctrl';
describe('vv.account.contact:ContactCtrl', () => {
let sut, accountEnumService, analyticsService;
beforeEach(() => {
accountEnumService = {
slides: {
contact: []
},
notifications: {
contact: {
success: {
title: 'title'
}
}
}
};
analyticsService = {
reportPage: jasmine.createSpy()
};
sut = new ContactCtrl(accountEnumService, analyticsService);
});
describe('constructor()', () => {
it('should set correct props', () => {
expect(sut._accountEnumService).toEqual(accountEnumService);
expect(sut._analyticsService).toEqual(analyticsService);
});
});
describe('$onInit()', () => {
it('should set correct props', () => {
sut.$onInit();
expect(sut.slides).toEqual(accountEnumService.slides.contact);
});
});
describe('onSubmitContact()', () => {
const formData = {};
it('should set correct props', () => {
sut.onSubmitContact(formData);
expect(sut.contactFormData).toBeDefined();
});
});
describe('onSubmitSaleforce()', () => {
it('should report page and show successfull notification', () => {
sut.onSubmitSaleforce();
expect(sut._analyticsService.reportPage).toHaveBeenCalledWith('contact', 'submitted');
expect(sut.notification).toEqual(sut._accountEnumService.notifications.contact.success);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment