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

41 lines
1.5 KiB
JavaScript

import './label-value.js';
import template from './label-value.html';
describe('Component vnInputTime', () => {
let $element;
let controller;
beforeEach(angular.mock.module('vnCore', $translateProvider => {
$translateProvider.translations('en', {});
}));
beforeEach(angular.mock.inject($componentController => {
const $attrs = {};
$element = angular.element(`${template}`);
controller = $componentController('vnLabelValue', {$element, $attrs});
}));
describe('applyTextContent()', () => {
it(`should set the value on the span element as there's no navigation setted`, () => {
const value = 'I am the value';
controller.value = value;
controller.title = value;
controller.applyTextContent();
expect(controller.element.querySelector('span').textContent).toEqual(value);
expect(controller.element.querySelector('span').title).toEqual(value);
});
it(`should set the value on the anchor element as there's a navigation setted`, () => {
const value = 'I am the value';
controller.value = value;
controller.title = value;
controller.state = 'some.state.to.go';
controller.applyTextContent();
expect(controller.element.querySelector('a').textContent).toEqual(value);
expect(controller.element.querySelector('a').title).toEqual(value);
});
});
});