85 lines
2.6 KiB
JavaScript
85 lines
2.6 KiB
JavaScript
describe('Testing ticketService', function () {
|
|
'use strict';
|
|
|
|
var ticketService,
|
|
$resource,
|
|
$httpBackend;
|
|
|
|
beforeEach(module('myitsmApp', 'ticketModule'));
|
|
|
|
beforeEach(inject(function (_ticketService_, _$resource_, _$httpBackend_) {
|
|
ticketService = _ticketService_;
|
|
$resource = _$resource_;
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
var getLocale = function () {
|
|
return readJSON('scripts/app/i18n/resources-locale_en.json');
|
|
};
|
|
|
|
var getMcsmInfo = function (type) {
|
|
var mockFileName = 'mocks/' + type + '-mcsm.json';
|
|
|
|
return readJSON(mockFileName);
|
|
};
|
|
|
|
var getIncidentInfo = function (type) {
|
|
var mockFileName = 'mocks/incident-put.json';
|
|
|
|
return readJSON(mockFileName);
|
|
};
|
|
|
|
$httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale());
|
|
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond('');
|
|
$httpBackend.whenGET('/smartit/rest/serverstates').respond('');
|
|
$httpBackend.whenGET('/smartit/rest/mcsm/incident/remedy/INC12345').respond(getMcsmInfo(EntityVO.TYPE_INCIDENT));
|
|
$httpBackend.whenGET('/smartit/rest/mcsm/change/remedy/CRQ322').respond(getMcsmInfo(EntityVO.TYPE_CHANGE));
|
|
$httpBackend.whenPUT('/smartit/rest/v2/incident/all/INC987').respond(getIncidentInfo());
|
|
}));
|
|
|
|
it('should exist', function () {
|
|
expect(ticketService).toBeDefined();
|
|
});
|
|
|
|
it('Should bring up the vendor details for incident', function () {
|
|
// this statement is to avoid the error from the $http service making a request to the application main page
|
|
$httpBackend.whenGET(/\.html$/).respond('');
|
|
|
|
var results;
|
|
|
|
ticketService.getVendorInfo('INC12345', EntityVO.TYPE_INCIDENT).then(function (response) {
|
|
results = response;
|
|
});
|
|
|
|
$httpBackend.flush();
|
|
expect(results[0].id).toEqual('AWS_1234');
|
|
});
|
|
|
|
it('Should bring up the vendor details for change', function () {
|
|
// this statement is to avoid the error from the $http service making a request to the application main page
|
|
$httpBackend.whenGET(/\.html$/).respond('');
|
|
|
|
var results;
|
|
|
|
ticketService.getVendorInfo('CRQ322', EntityVO.TYPE_CHANGE).then(function (response) {
|
|
results = response;
|
|
});
|
|
|
|
$httpBackend.flush();
|
|
expect(results[0].id).toEqual('JIRA_1234');
|
|
});
|
|
|
|
it('should update data for incident', function () {
|
|
// this statement is to avoid the error from the $http service making a request to the application main page
|
|
$httpBackend.whenGET(/\.html$/).respond('');
|
|
|
|
var results;
|
|
|
|
ticketService.update('INC987', EntityVO.TYPE_INCIDENT).then(function (response) {
|
|
results = response;
|
|
});
|
|
|
|
$httpBackend.flush();
|
|
expect(results.id).toEqual('IDGAA5V0GEWV0AOSVP6NRG1CEA4UIC');
|
|
});
|
|
});
|