SmartIT_Extensions/BMC/smart-it-full/test/app/create/create-ticket-model.spec.js

73 lines
2.1 KiB
JavaScript

describe('Testing createTicketModel', function () {
'use strict';
var createTicketModel, objectValueMapperService, fieldList;
beforeEach(module('myitsmApp', 'createTicketModule'));
beforeEach(inject(function (_createTicketModel_, _objectValueMapperService_) {
createTicketModel = _createTicketModel_;
objectValueMapperService = _objectValueMapperService_;
fieldList = {
siteName: {
name: 'siteName',
ootb: true,
value: 'abc'
},
siteRegion: {
name: 'siteRegion',
ootb: true,
value: 'abc'
},
siteGroup: {
name: 'siteGroup',
ootb: true,
value: 'abc'
}
};
fieldList.siteName = new FieldVO().build(fieldList.siteName);
fieldList.siteRegion = new FieldVO().build(fieldList.siteRegion);
fieldList.siteGroup = new FieldVO().build(fieldList.siteGroup);
spyOn(objectValueMapperService, 'getFieldList').and.returnValue(fieldList);
}));
it('should exist', function () {
expect(createTicketModel).toBeDefined();
});
it('should have getList', function () {
expect(createTicketModel.getList).toBeDefined();
});
it('should have getPersonsByCompany', function () {
expect(createTicketModel.getPersonsByCompany).toBeDefined();
});
it('should have getListOfRegionsByName', function () {
expect(createTicketModel.getListOfRegionsByName).toBeDefined();
});
it('should have getListOfSiteGroupsByName', function () {
expect(createTicketModel.getListOfSiteGroupsByName).toBeDefined();
});
it('should have collectTicketChanges', function () {
expect(createTicketModel.collectTicketChanges).toBeDefined();
});
it('should run collectTicketChanges and collect change location', function () {
var changeMetadata = {
ootbMapping: {
siteName: ['location.name'],
siteRegion: ['location.region'],
siteGroup: ['location.siteGroup']
}
};
var changeList = createTicketModel.collectTicketChanges(changeMetadata);
console.log('Ank:'+JSON.stringify(changeList));
expect(changeList.location.name).toEqual('abc');
expect(changeList.location.region).toEqual('abc');
expect(changeList.location.siteGroup).toEqual('abc');
});
});