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(['MultiPhone'], function() {
'use strict';

describe("Multi-Phone directive", function (){
var focusServiceMock,
isolated,
timeout,
phone = { system: "phone",use: "Office", value: "(717) 818-9999" },
emptyPhone = { system: "phone", use: "", value: "" },
options = ['o1', 'o2'];

beforeEach(function () {
module('angularTemplateApp');

focusServiceMock = jasmine.createSpyObj('focusService', ['focusElement']);

module(function($provide){
$provide.value('focusService', focusServiceMock);
});

inject(function($compile, $rootScope, $templateCache, $timeout) {
var scope = $rootScope.$new(),
compiled,
element = angular.element("<multi-phone ng-model='telecom' primary-label='primary' secondary-label='secondary' type-options='options'></multi-phone>");

timeout = $timeout;

scope.telecom = [phone];
scope.options = options;
scope.primary = 'Primary';
scope.secondary = 'Secondary';

$templateCache.put('modules/ui-components/form/controls/composite/input-multi-phone/multi-phone_template.html', '');

compiled = $compile(element)(scope);
scope.$digest();
isolated = compiled.isolateScope();
});
});

describe("link variables", function () {
it ("should be correct", function() {
expect(isolated.ngModel).toEqual([phone])
expect(isolated.primaryLabel).toBe('Primary');
expect(isolated.secondaryLabel).toBe('Secondary');
expect(isolated.typeOptions).toEqual(options);
});
});

describe("link functions", function () {
it ("should add a new phone object to the model and focus", function() {
isolated.addPhone();
timeout.flush()
expect(isolated.ngModel).toEqual([phone, emptyPhone]);
expect(focusServiceMock.focusElement).toHaveBeenCalled();
});

it ("should delete a phone object and focus", function() {
isolated.deletePhone(0);
timeout.flush()
expect(isolated.ngModel).toEqual([]);
expect(focusServiceMock.focusElement).toHaveBeenCalled();
});
});
});
});