V
V
Vitaliy Semyanchuk2014-07-17 15:10:38
Canvas
Vitaliy Semyanchuk, 2014-07-17 15:10:38

How to write unit tests for fabricjs on jasmine?

Hello.
There is a project to write using the fabric js library, and accordingly you need to test it. Well, the problem is that most of the functions there contain the canvas.getActiveObject() line, and I don’t understand if it’s possible to emulate object clicks in jasmine?
Here is an example at plnkr.co/edit/V8yh08FtJy4qaQMc87qE?p=preview
There is a button on which the fontBold() function is hung in it code

var obj = canvas.getActiveObject();
        if (!obj) return;
        obj.fontWeight = (obj.fontWeight === 'bold') ? 'normal' : 'bold';
        canvas.renderAll();

so when I check it in tests, it does not see canvas.getActiveObject() , and now I need to somehow emulate this action.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question