SmartIT_Extensions/BMC/smart-it-full/test/app/common/history-controller.spec.js

47 lines
1.5 KiB
JavaScript

describe('HistoryController', function () {
'use strict';
var $httpBackend;
beforeEach(module('myitsmApp', 'templates'));
beforeEach(inject(function ($injector, $rootScope, $controller, historyModel) {
this.scope = $rootScope.$new();
this.controller = $controller;
this.historyModel = historyModel;
$httpBackend = $injector.get('$httpBackend');
$httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(readJSON('scripts/app/i18n/resources-locale_en.json'));
$httpBackend.whenGET('/smartit/rest/serverstates').respond(200);
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200);
this.controllerInstance = this.controller('HistoryController', {
$scope: this.scope
});
}));
beforeEach(inject(function ($q) {
var deferred = $q.defer();
var success = 'test success';
spyOn(this.historyModel, "clearHistory").and.callFake(function () {
deferred.resolve(success);
return deferred.promise;
});
}));
afterEach(inject(function ($rootScope) {
var $rootScope = $rootScope;
$rootScope.$apply();
}));
it('should defined', function () {
expect(this.controllerInstance).toBeDefined();
});
it('shoul run clearHistory ()', function () {
this.scope.clearHistory();
this.scope.$apply();
expect(this.historyModel.clearHistory).toHaveBeenCalled();
});
});