195 lines
6.7 KiB
JavaScript
195 lines
6.7 KiB
JavaScript
/*** Created by npatil2.*/
|
|
describe('service: emailModel', function () {
|
|
var $httpBackend, $rootScope, scope, response;
|
|
|
|
beforeEach(module('myitsmApp'));
|
|
beforeEach(inject(function ($rootScope, $injector, attachmentService, feedModel, userModel, systemAlertService) {
|
|
scope = $rootScope.$new();
|
|
this.attachmentService = attachmentService;
|
|
this.feedModel = feedModel;
|
|
this.userModel = userModel;
|
|
this.systemAlertService = systemAlertService;
|
|
$httpBackend = $injector.get('$httpBackend');
|
|
|
|
var getLocale = function () {
|
|
return readJSON('scripts/app/i18n/resources-locale_en.json');
|
|
};
|
|
|
|
$httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale());
|
|
$httpBackend.whenGET('/smartit/rest/serverstates').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200);
|
|
$httpBackend.whenGET('views/dashboard/index.html').respond(200);
|
|
|
|
$rootScope = $injector.get('$rootScope');
|
|
this.emailModel = $injector.get('emailModel');
|
|
}));
|
|
|
|
beforeEach(inject(function ($q) {
|
|
var deferred = $q.defer(), data = 'success', request = {
|
|
worknote: 'this is for test',
|
|
access: true,
|
|
'Email.From.Person': {
|
|
email: 'A.Allbrook@calbroservices.com',
|
|
fullName: 'Allen Allbrook',
|
|
loginId: 'Allen'
|
|
},
|
|
'Email.Subject': 'RLM223: evdfvfvf',
|
|
'Email.Body': 'this is for test',
|
|
'Email.To.InternetEmail': '',
|
|
'Email.To.Person': [
|
|
{
|
|
email: 'Allen@gmail.com',
|
|
loginId: 'PPL000000000110',
|
|
fullName: 'Allen AB'
|
|
}
|
|
]
|
|
};
|
|
|
|
spyOn(this.attachmentService, 'prepareFileToUpload').and.callFake(function () {
|
|
deferred.resolve(data);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.feedModel, 'saveNoteBulk').and.callFake(function () {
|
|
deferred.resolve(request);
|
|
return deferred.promise;
|
|
});
|
|
|
|
|
|
}));
|
|
|
|
it('should be defined', function () {
|
|
expect(this.emailModel).toBeDefined();
|
|
});
|
|
|
|
it('should create Email ', function () {
|
|
this.ticketData = [
|
|
{
|
|
type: 'release',
|
|
crossLaunchURL: '',
|
|
impactedService: null,
|
|
businessJustification: 'Corporate Strategic',
|
|
coordinator: {
|
|
fullName: 'Allen Allbrook',
|
|
loginId: 'Allen',
|
|
jid: 'allen_000000000000001',
|
|
available: "OFFLINE",
|
|
following: false,
|
|
customFields: {},
|
|
id: 'Allen'
|
|
},
|
|
coordinatorGroup: {
|
|
name: 'Frontoffice Support',
|
|
company: {
|
|
name: 'Calbro Services'
|
|
},
|
|
organization: 'IT Support',
|
|
id: 'SGP000000000010'
|
|
},
|
|
timing: '',
|
|
timingReason: '',
|
|
manager: null,
|
|
completedDate: null,
|
|
scheduledEndDate: null
|
|
|
|
}
|
|
];
|
|
this.recipients = 'test';
|
|
response = this.emailModel.createEmail(this.ticketData, this.recipients);
|
|
expect(this.emailModel.emailInstances).toBeTruthy();
|
|
expect(this.emailModel.emailInstances[0].ticketData[0].type).toEqual('release');
|
|
});
|
|
|
|
it('should add Attachment', function () {
|
|
this.fileInput = '<input type="file" ie-activate-by-enter="" onchange="angular.element(this).scope().addEmailAttachment(this)" class="attach-tool__file-input" title="Attach..." aria-label="Attach..." tabindex="0" role="link">';
|
|
response = this.emailModel.addAttachment(this.fileInput).then(function (data) {
|
|
response = data;
|
|
});
|
|
|
|
|
|
scope.$apply();
|
|
expect(response).toEqual('success');
|
|
});
|
|
|
|
|
|
it('should sendEmail ', function () {
|
|
this.email = {
|
|
headerText: 'RLM223: evdfvfvf',
|
|
recipientInputText: '',
|
|
attachment: 'test',
|
|
kba: 'test1',
|
|
ticketList: [{
|
|
workNoteType: 'test'
|
|
}],
|
|
senderList: [
|
|
{
|
|
email: 'Allen@gmail.com',
|
|
fullName: 'Allen AB',
|
|
loginId: 'PPL000000000110',
|
|
internal: true,
|
|
type: '',
|
|
$$hashKey: 'object:1183'
|
|
}
|
|
],
|
|
subjectText: 'RLM223: evdfvfvf',
|
|
messageBody: 'this is for test',
|
|
ticketType: 'release',
|
|
ticketId: 'RLGAA5V0HGOHVAOYZT29OYD69AJ7EL'
|
|
};
|
|
|
|
this.internalRecip = [
|
|
{
|
|
email: 'Allen@gmail.com',
|
|
fullName: 'Allen AB',
|
|
loginId: 'PPL000000000110',
|
|
internal: true,
|
|
type: '',
|
|
$$hashKey: 'object:1183'
|
|
}
|
|
];
|
|
this.externalRecip = 'test';
|
|
this.userModel.userFullData = {
|
|
accessRestrictions: [
|
|
{
|
|
name: 'Calbro Services'
|
|
}
|
|
],
|
|
available: 'OFFLINE',
|
|
availableForAssignment: true,
|
|
cell: '1 212',
|
|
company: {
|
|
name: 'Calbro Services',
|
|
site: {
|
|
name: 'Headquarters, Building 1.31',
|
|
address: {
|
|
street: '1114 Eighth Avenue, 31st Floor.',
|
|
city: 'New York',
|
|
state: 'New York',
|
|
country: 'United States',
|
|
zip: '10036',
|
|
address: '1114 Eighth Avenue, 31st Floor.\r\nNew York, New York 10036\r\nUnited States'
|
|
},
|
|
region: 'Americas',
|
|
siteGroup: 'United States',
|
|
siteId: 'STE_SOLN0002846'
|
|
}
|
|
},
|
|
costCenter: '225276-A',
|
|
createDate: 1226003984000,
|
|
customFields: {},
|
|
entityLink: '#/person/Allen'
|
|
};
|
|
|
|
this.emailModel.sendEmail(this.email, this.internalRecip, this.externalRecip).then(function (data) {
|
|
response = data
|
|
}
|
|
);
|
|
scope.$apply();
|
|
expect(response.worknote).toEqual('this is for test');
|
|
});
|
|
|
|
it('should delete Email ', function () {
|
|
this.emailModel.deleteEmailWindow(this.emailWindow);
|
|
expect(this.emailModel.emailInstances).toBeDefined();
|
|
});
|
|
}); |