55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
describe('Testing ticketModel', function () {
|
|
'use strict';
|
|
|
|
var ticketModel, $httpBackend;
|
|
|
|
beforeEach(module('myitsmApp'));
|
|
|
|
beforeEach(inject(function ($injector, $rootScope, _ticketModel_, ticketService) {
|
|
$httpBackend = $injector.get('$httpBackend');
|
|
this.$rootScope = $rootScope;
|
|
this.scope = $rootScope.$new();
|
|
ticketModel = _ticketModel_;
|
|
this.ticketService = ticketService;
|
|
|
|
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);
|
|
}));
|
|
|
|
beforeEach(inject(function ($q) {
|
|
var deferred = $q.defer(), data = {};
|
|
spyOn(this.ticketService, 'getBasicInformation').and.callFake(function () {
|
|
var ticketData = {
|
|
id: 123
|
|
};
|
|
deferred.resolve(ticketData);
|
|
return deferred.promise;
|
|
});
|
|
spyOn(ticketModel, 'getTicketAttachments').and.callFake(function () {
|
|
deferred.resolve(data);
|
|
return deferred.promise;
|
|
});
|
|
}));
|
|
|
|
it('should exist', function () {
|
|
expect(ticketModel).toBeDefined();
|
|
});
|
|
|
|
it('should have getVendorInfo', function () {
|
|
expect(ticketModel.getVendorInfo).toBeDefined();
|
|
});
|
|
|
|
it('should return ticket data', function () {
|
|
ticketModel.cache = [];
|
|
var ticketId = 123;
|
|
ticketModel.getTicket(ticketId, EntityVO.TYPE_INCIDENT, false);
|
|
this.scope.$apply();
|
|
expect(ticketModel.cache[ticketId].id).toEqual(ticketId);
|
|
});
|
|
}); |