vendredi 16 novembre 2018

Testing Div Sizing Changes

I'm trying to find a workable way to set up some jest/enzyme tests for a size watcher component in a react project.

at present i'm watching the clientWidth and clientHeight of a wrapper div to check for sizing changes from the parent. The div itself is styled to fill its parent box with no extraneous border/whitespace i.e., width: 100%, height 100%, margin/padding 0px... etc.

this brings me to my issue. what is a good way to create a mock/wrapper to test this with? I cannot directly alter clientWidth or 'clientHeight` as they are protected, and since i'm using just/enzyme, modifications to parent css styling do not really "flow" like they do in a browser. i don't really have access to anything like jquery to "cheat" so... any advice on how to create a test scenario for this?

Aucun commentaire:

Enregistrer un commentaire