97 lines
3.3 KiB
JavaScript
97 lines
3.3 KiB
JavaScript
/**
|
|
* Created by npatil2 .
|
|
*/
|
|
describe('service: consoleColumnsModel', function () {
|
|
var $httpBackend, $rootScope, scope, response, myResult;
|
|
|
|
beforeEach(module('myitsmApp'));
|
|
beforeEach(inject(function ($rootScope, $injector, consoleService) {
|
|
scope = $rootScope.$new();
|
|
this.consoleService = consoleService;
|
|
|
|
$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.consoleColumnsModel = $injector.get('consoleColumnsModel');
|
|
}));
|
|
|
|
beforeEach(inject(function ($q) {
|
|
var deferred = $q.defer(), data = {
|
|
itemList: [
|
|
{
|
|
name: 'customerName',
|
|
visible: false,
|
|
ootbMaping: [
|
|
'customer.fullName'
|
|
],
|
|
type: 'system',
|
|
field: {
|
|
name: 'customerFullName',
|
|
label: 'Customer Full Name',
|
|
arFieldName: "CUSTOMERFULLNAME",
|
|
required: false,
|
|
editable: true,
|
|
type: 'characterField'
|
|
}
|
|
},
|
|
{
|
|
name: 'workOrderType',
|
|
visible: false,
|
|
ootbMaping: [
|
|
'workOrderType'
|
|
],
|
|
type: 'system'
|
|
}
|
|
]
|
|
};
|
|
|
|
spyOn(this.consoleService, 'getTicketAvailableColumnsList').and.callFake(function () {
|
|
deferred.resolve(data);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.consoleService, 'consoleRefreshMetadata').and.callFake(function () {
|
|
deferred.resolve(data);
|
|
return deferred.promise;
|
|
});
|
|
}));
|
|
|
|
it('should be defined', function () {
|
|
expect(this.consoleColumnsModel).toBeDefined();
|
|
});
|
|
|
|
it('should return Ticket Available Columns List ', function () {
|
|
|
|
this.consoleColumnsModel.getTicketAvailableColumnsList().then(function (data) {
|
|
myResult = data;
|
|
});
|
|
|
|
scope.$apply();
|
|
expect(myResult.itemList).toBeTruthy();
|
|
expect(myResult.itemList[0].name).toEqual('customerName');
|
|
expect(myResult.itemList[0].visible).toBe(false);
|
|
expect(myResult.itemList[0].type).toEqual('system');
|
|
});
|
|
|
|
it('should console Refresh Metadata', function () {
|
|
|
|
this.consoleColumnsModel.consoleRefreshMetadata().then(function (data) {
|
|
myResult = data;
|
|
});
|
|
scope.$apply();
|
|
|
|
expect(myResult.itemList).toBeTruthy();
|
|
expect(myResult.itemList[0].name).toEqual('customerName');
|
|
expect(myResult.itemList[0].visible).toBe(false);
|
|
expect(myResult.itemList[0].type).toEqual('system');
|
|
});
|
|
}); |