salix/front/core/components/textarea/index.spec.js

58 lines
1.6 KiB
JavaScript

import './index.js';
describe('Component vnTextarea', () => {
let $element;
let $ctrl;
beforeEach(ngModule('vnCore'));
beforeEach(inject(($compile, $rootScope) => {
$element = $compile(`<vn-textarea></vn-textarea>`)($rootScope);
$ctrl = $element.controller('vnTextarea');
}));
afterEach(() => {
$element.remove();
});
describe('rows() setter', () => {
it(`should set rows property of the element to the given value if it's a valid number`, () => {
$ctrl.rows = 27;
expect($ctrl.rows).toEqual(27);
});
it(`should set rows property of the element to 3 if the given value if it's null`, () => {
$ctrl.rows = null;
expect($ctrl.rows).toEqual(3);
});
it(`should set rows property of the element to 3 if the given value if it's not a valid number`, () => {
$ctrl.rows = 'a';
expect($ctrl.rows).toEqual(3);
});
});
describe('maxlength() setter', () => {
it(`should set maxlength property of the element to the given value if it's a valid number`, () => {
$ctrl.maxlength = 100;
expect($ctrl.maxlength).toEqual('100');
});
it(`should set maxlength property of the element to 3 if the given value if it's null`, () => {
$ctrl.maxlength = null;
expect($ctrl.maxlength).toEqual('50');
});
it(`should set maxlength property of the element to 3 if the given value if it's not a valid number`, () => {
$ctrl.maxlength = 'a';
expect($ctrl.maxlength).toEqual('50');
});
});
});