49 lines
2.0 KiB
JavaScript
49 lines
2.0 KiB
JavaScript
describe('Test check multiline directive', function () {
|
|
var compile, scope, $httpBackend;
|
|
|
|
beforeEach(module('myitsmApp'));
|
|
beforeEach(function () {
|
|
inject(function ($compile, $rootScope, $injector) {
|
|
$httpBackend = $injector.get('$httpBackend');
|
|
var getLocale = function () {
|
|
return readJSON('scripts/app/i18n/resources-locale_en.json');
|
|
};
|
|
|
|
$httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale());
|
|
$httpBackend.whenGET('/smartit/rest/v2/metadata?type=global').respond(200);
|
|
compile = $compile;
|
|
scope = $rootScope.$new();
|
|
});
|
|
});
|
|
|
|
function getCompiledElement(multilineContent) {
|
|
if (!multilineContent) {
|
|
multilineContent = 'This is one line text.';
|
|
}
|
|
var element = angular.element('<div check-multiline multiline-max-height="80" multiline-content="multilineContent" is-content-multiline="false"><h2 data-ellipsis>' + multilineContent + '</h2></div>'),
|
|
compiledElement = compile(element)(scope);
|
|
|
|
scope.$digest();
|
|
return compiledElement;
|
|
}
|
|
|
|
it('should compile and set isContentMultiline to false if content is of single line', function () {
|
|
var multilineContent = 'This is one line text.',
|
|
directiveElem = getCompiledElement(multilineContent),
|
|
divElem = directiveElem[0],
|
|
isolateScope = directiveElem.isolateScope();
|
|
|
|
expect(divElem).toBeDefined();
|
|
expect(isolateScope.isContentMultiline).toBeFalsy();
|
|
});
|
|
|
|
it('should successfully watch multilineContent model and set isContentMultiline to false if multilineContent is of one line', function () {
|
|
var directiveElem = getCompiledElement(),
|
|
isolateScope = directiveElem.isolateScope();
|
|
|
|
isolateScope.multilineContent = 'This is content.';
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.isContentMultiline).toBeFalsy();
|
|
});
|
|
}); |