Summary Table
| Categories |
Total Count |
| PII |
0 |
| URL |
0 |
| DNS |
0 |
| EKL |
0 |
| IP |
0 |
| PORT |
0 |
| VsID |
0 |
| CF |
0 |
| AI |
0 |
| VPD |
0 |
| PL |
0 |
| Other |
0 |
File Content
define(['DirectSchedulingService','InstitutionChoiceController'], function () {
'use strict';
describe('Institution choice controller', function () {
var scope,
controller,
mhpuser,
stateMock,
stateParamsMock,
institutionsServiceMock,
validationSummaryMock;
beforeEach(function () {
module('angularTemplateApp');
mhpuser = {
facilityName: 'Test Facility',
firstName: 'Test First',
lastName: 'Test Last'
};
stateMock = {
go: function () {}
};
stateParamsMock = {
moduleName: "VAR Utility",
primaryHeaderTitle: "Select Facility Location"
};
institutionsServiceMock = {
institutions: {
data: [
{divisionName: 'Division 2'},
{divisionName: 'Division 1'},
{divisionName: mhpuser.facilityName},
]
},
setActiveInstitution: function () {
}
};
spyOn(institutionsServiceMock, 'setActiveInstitution');
spyOn(stateMock, 'go');
validationSummaryMock = jasmine.createSpyObj('validationSummary', ['validate']);
module(function ($provide) {
$provide.value('mhpuser', mhpuser);
$provide.value('$state', stateMock);
$provide.value('$stateParams', stateParamsMock);
$provide.value('InstitutionsService', institutionsServiceMock);
});
inject(function ($rootScope, $controller) {
scope = $rootScope.$new();
validationSummaryMock.validate.andCallFake( function(){
return {
then: function(callback) { return callback(); }
};
});
controller = $controller('InstitutionChoiceController', {
$scope: scope,
$stateParams: stateParamsMock,
});
scope.institutionsChoiceForm = {
validationSummary: validationSummaryMock,
$setSubmitted: function (){}
};
});
});
it('sets scope variables properly from service values and state params', function () {
expect(scope.primaryHeaderTitle).toEqual('VAR Utility - Select Facility Location');
expect(scope.parentFacilityName).toEqual('Test Facility');
expect(scope.userFirstLastName).toEqual('Test First Test Last');
});
it('on openSettings() sets the active institution in the institutions service and forwards the user to the main var-utility page', function () {
var institutionSelection = {
divisionName: 'Test Facility'
};
scope.openSettings(institutionSelection.divisionName);
expect(institutionsServiceMock.setActiveInstitution)
.toHaveBeenCalledWith(institutionSelection);
expect(stateMock.go)
.toHaveBeenCalledWith("main.auth.two-panel.secondary-navigation.var-utility");
});
it('should sort institution dropdown options alphabetically, but always put the parent facility first', function () {
expect(scope.institutionOptions).toEqual([mhpuser.facilityName, 'Division 1', 'Division 2']);
});
});
});