salix/front/core/components/label-value/index.spec.js

37 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-10-26 10:04:48 +00:00
import './index.js';
describe('Component vnLabelValue', () => {
let $element;
let controller;
let element;
beforeEach(ngModule('vnCore'));
beforeEach(inject(($compile, $rootScope) => {
$element = $compile(`<vn-label-value></vn-label-value>`)($rootScope);
controller = $element.controller('vnLabelValue');
element = $element[0];
}));
afterEach(() => {
$element.remove();
});
describe('value() setter', () => {
it(`should set the value on the span element`, () => {
const value = 'I am the value';
controller.value = value;
expect(element.querySelector('span').textContent).toEqual(value);
expect(element.querySelector('span').title).toEqual(value);
});
it(`should set a dash when no value is provided`, () => {
const value = null;
controller.value = value;
expect(element.querySelector('span').textContent).toEqual('-');
});
});
});