3 describe('crmCaseType', function() {
13 beforeEach(function() {
17 // CRM_Case_XMLProcessor::REL_TYPE_CNAME
19 'REL_TYPE_CNAME': 'label_b_a'
21 module('crmCaseType');
22 module('crmJsonComparator');
23 inject(function(crmJsonComparator
) {
24 crmJsonComparator
.register(jasmine
);
28 beforeEach(inject(function(_
$controller_
, _
$compile_
, _
$httpBackend_
, _
$rootScope_
) {
29 $controller
= _
$controller_
;
30 $compile
= _
$compile_
;
31 $httpBackend
= _
$httpBackend_
;
32 $rootScope
= _
$rootScope_
;
35 describe('CaseTypeCtrl', function() {
36 beforeEach(function () {
42 "option_group_id": "25",
55 "option_group_id": "25",
71 "option_group_id": "28",
85 "option_group_id": "28",
102 "option_group_id": "2",
103 "label": "ADC referral",
105 "name": "ADC referral",
116 "option_group_id": "2",
117 "label": "Add Client To Case",
119 "name": "Add Client To Case",
131 "option_group_id": "2",
132 "label": "Open Case",
142 "icon": "fa-folder-open-o"
146 "option_group_id": "2",
147 "label": "Medical evaluation",
149 "name": "Medical evaluation",
164 "name_a_b": "Benefits Specialist is",
165 "label_a_b": "Benefits Specialist is",
166 "name_b_a": "Benefits Specialist",
167 "label_b_a": "Benefits Specialist",
168 "description": "Benefits Specialist",
169 "contact_type_a": "Individual",
170 "contact_type_b": "Individual",
176 "name_a_b": "Case Coordinator is",
177 "label_a_b": "Case Coordinator is",
178 "name_b_a": "Case Coordinator",
179 "label_b_a": "Case Coordinator",
180 "description": "Case Coordinator",
181 "contact_type_a": "Individual",
182 "contact_type_b": "Individual",
190 "name": "housing_support",
191 "title": "Housing Support",
192 "description": "Help homeless individuals obtain temporary and long-term housing",
200 {"name": "Open Case", "max_instances": "1"}
204 "name": "standard_timeline",
205 "label": "Standard Timeline",
210 "status": "Completed"
213 "name": "Medical evaluation",
214 "reference_activity": "Open Case",
215 "reference_offset": "1",
216 "reference_select": "newest"
223 "name": "Homeless Services Coordinator",
231 scope
= $rootScope
.$new();
232 ctrl
= $controller('CaseTypeCtrl', {$scope
: scope
, apiCalls
: apiCalls
});
235 it('should load activity statuses', function() {
236 expect(scope
.activityStatuses
).toEqualData(apiCalls
.actStatuses
.values
);
239 it('should load activity types', function() {
240 expect(scope
.activityTypes
['ADC referral']).toEqualData(apiCalls
.actTypes
.values
[0]);
243 it('addActivitySet should add an activitySet to the case type', function() {
244 scope
.addActivitySet('timeline');
245 var activitySets
= scope
.caseType
.definition
.activitySets
;
246 var newSet
= activitySets
[activitySets
.length
- 1];
247 expect(newSet
.name
).toBe('timeline_1');
248 expect(newSet
.timeline
).toBe('1');
249 expect(newSet
.label
).toBe('Timeline');
252 it('addActivitySet handles second timeline correctly', function() {
253 scope
.addActivitySet('timeline');
254 scope
.addActivitySet('timeline');
255 var activitySets
= scope
.caseType
.definition
.activitySets
;
256 var newSet
= activitySets
[activitySets
.length
- 1];
257 expect(newSet
.name
).toBe('timeline_2');
258 expect(newSet
.timeline
).toBe('1');
259 expect(newSet
.label
).toBe('Timeline #2');
263 describe('crmAddName', function () {
266 beforeEach(function() {
267 scope
= $rootScope
.$new();
268 scope
.activityTypeOptions
= [1, 2, 3];
269 element
= '<span crm-add-name crm-options="activityTypeOptions"></span>';
271 spyOn(CRM
.$.fn
, 'crmSelect2').and
.callThrough();
273 element
= $compile(element
)(scope
);
277 describe('when initialized', function () {
280 beforeEach (function () {
281 var dataFunction
= CRM
.$.fn
.crmSelect2
.calls
.argsFor(0)[0].data
;
282 returnValue
= dataFunction();
285 it('updates the UI with updated value of scope variable', function () {
286 expect(returnValue
).toEqual({ results
: scope
.activityTypeOptions
});
291 describe('CaseTypeListCtrl', function () {
294 beforeEach(function () {
302 scope
= $rootScope
.$new();
303 ctrl
= $controller('CaseTypeListCtrl', {
309 it('should store an index of case types', function() {
310 expect(scope
.caseTypes
).toEqual(caseTypes
.values
);