2018-09-04 08:11:01 +00:00
|
|
|
import './textarea.js';
|
|
|
|
|
|
|
|
describe('Component vnTextarea', () => {
|
|
|
|
let $scope;
|
|
|
|
let $attrs;
|
|
|
|
let $element;
|
|
|
|
let controller;
|
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2018-09-04 08:11:01 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
|
2018-09-04 08:11:01 +00:00
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$attrs = {};
|
|
|
|
$element = angular.element('<vn-textarea vn-three label="Observation" field="$ctrl.claim.observation" rows="9"><textarea></vn-textarea>');
|
|
|
|
$element[0].firstChild.MaterialTextfield = {updateClasses_: () => {}};
|
2018-12-22 10:59:26 +00:00
|
|
|
controller = $componentController('vnTextarea', {$scope, $element, $attrs});
|
2018-09-04 08:11:01 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('model() setter', () => {
|
|
|
|
it(`should set model and call mdlUpdate`, () => {
|
|
|
|
spyOn(controller, 'mdlUpdate');
|
|
|
|
let model = 'model';
|
|
|
|
controller.model = model;
|
|
|
|
|
|
|
|
expect(controller._model).toEqual(model);
|
|
|
|
expect(controller.mdlUpdate).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('rows() setter', () => {
|
|
|
|
it(`should set rows property of the element to the given value if its not null`, () => {
|
|
|
|
controller.rows = 27;
|
|
|
|
|
|
|
|
expect(controller.textarea.rows).toEqual(27);
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should set rows property of the element to 3 if the given value if its null`, () => {
|
|
|
|
controller.rows = null;
|
|
|
|
|
|
|
|
expect(controller.textarea.rows).toEqual(3);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('mdlUpdate()', () => {
|
|
|
|
it(`should should call mdlField.updateClasses if theres an mdlField defined and call upgradeElement with the textarea element`, () => {
|
|
|
|
spyOn($element[0].firstChild.MaterialTextfield, 'updateClasses_');
|
|
|
|
spyOn(componentHandler, 'upgradeElement');
|
|
|
|
controller.mdlUpdate();
|
|
|
|
|
|
|
|
expect($element[0].firstChild.MaterialTextfield.updateClasses_).toHaveBeenCalledWith();
|
|
|
|
expect(componentHandler.upgradeElement).toHaveBeenCalledWith(controller.element[0].firstChild);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|