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

58 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-10-09 22:47:29 +00:00
import './index.js';
describe('Component vnTextarea', () => {
let $element;
let $ctrl;
beforeEach(ngModule('vnCore'));
2019-10-09 22:47:29 +00:00
2020-07-23 14:46:16 +00:00
beforeEach(inject(($compile, $rootScope) => {
2019-10-09 22:47:29 +00:00
$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);
});
});
2020-01-14 08:10:54 +00:00
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');
});
});
2019-10-09 22:47:29 +00:00
});