Within my custom directive, I have implemented the following functionality:
link: function (scope, element) {
var editor = CKEDITOR.inline(element.find('div[contenteditable]')[0], {}
To ensure that the directive is properly linked and that the editor is successfully created within the element
using the CKEDITOR.inline
method, I have written this test:
it('should compile', function () {
var element = angular.element('<directive></directive>');
var compiled = $compile(element)(scope);
$('body').append(compiled);
expect(element.find('.ckeditor')).toExist();
});
However, a challenge arises as CKEDITOR
updates the DOM asynchronously:
CKEDITOR.inline = function(element) {
setTimeout(function() {
element.append('<div class=ckeditor></div>');
},0);
}
As a result, the test fails to locate the element with the specified class due to the asynchronous nature of the element insertion. How can I address this issue in testing?