From b109dd8b53921163fdc1be3d56e14ac3d040eab0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ren=C3=A9=20Olivo?= Date: Mon, 23 Apr 2018 19:09:03 -0400 Subject: [PATCH] Define common dependencies at the top of the spec file --- tests/karma/unit/crmCaseTypeSpec.js | 35 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/karma/unit/crmCaseTypeSpec.js b/tests/karma/unit/crmCaseTypeSpec.js index a7295b6944..9e9e5e839c 100644 --- a/tests/karma/unit/crmCaseTypeSpec.js +++ b/tests/karma/unit/crmCaseTypeSpec.js @@ -1,6 +1,14 @@ 'use strict'; describe('crmCaseType', function() { + var $controller; + var $compile; + var $httpBackend; + var $rootScope; + var apiCalls; + var ctrl; + var compile; + var scope; beforeEach(function() { CRM.resourceUrls = { @@ -17,19 +25,15 @@ describe('crmCaseType', function() { }); }); - describe('CaseTypeCtrl', function() { - var apiCalls; - var ctrl; - var compile; - var $httpBackend; - var scope; - var timeout; + beforeEach(inject(function(_$controller_, _$compile_, _$httpBackend_, _$rootScope_) { + $controller = _$controller_; + $compile = _$compile_; + $httpBackend = _$httpBackend_; + $rootScope = _$rootScope_; + })); - beforeEach(inject(function(_$httpBackend_, $rootScope, $controller, $compile, $timeout) { - $httpBackend = _$httpBackend_; - scope = $rootScope.$new(); - compile = $compile; - timeout = $timeout; + describe('CaseTypeCtrl', function() { + beforeEach(function () { apiCalls = { actStatuses: { values: [ @@ -224,8 +228,9 @@ describe('crmCaseType', function() { } } }; + scope = $rootScope.$new(); ctrl = $controller('CaseTypeCtrl', {$scope: scope, apiCalls: apiCalls}); - })); + }); it('should load activity statuses', function() { expect(scope.activityStatuses).toEqualData(apiCalls.actStatuses.values); @@ -259,7 +264,7 @@ describe('crmCaseType', function() { var scope; var element; - beforeEach(inject(function($rootScope, $compile) { + beforeEach(function() { scope = $rootScope.$new(); scope.activityTypeOptions = [1, 2, 3]; element = ''; @@ -268,7 +273,7 @@ describe('crmCaseType', function() { element = $compile(element)(scope); scope.$digest(); - })); + }); describe('when initialized', function () { var returnValue; -- 2.25.1