mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
Merge pull request #609 from prymitive/fix-repack
fix(ui): don't crash on null grid
This commit is contained in:
@@ -44,7 +44,7 @@ const AlertGrid = observer(
|
||||
// used to call forcePack() which will repack all grid elements
|
||||
// (alert groups), this needs to be called if any group size changes
|
||||
masonryRepack = action(() => {
|
||||
if (this.masonryComponentReference.ref !== false) {
|
||||
if (this.masonryComponentReference.ref) {
|
||||
this.masonryComponentReference.ref.forcePack();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -104,6 +104,24 @@ describe("<AlertGrid />", () => {
|
||||
expect(repackSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("masonryRepack() doesn't crash when masonryComponentReference.ref=null`", () => {
|
||||
const tree = ShallowAlertGrid();
|
||||
const instance = tree.instance();
|
||||
const repackSpy = jest.spyOn(instance, "masonryRepack");
|
||||
instance.masonryComponentReference.ref = null;
|
||||
instance.componentDidUpdate();
|
||||
expect(repackSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("masonryRepack() doesn't crash when masonryComponentReference.ref=undefined`", () => {
|
||||
const tree = ShallowAlertGrid();
|
||||
const instance = tree.instance();
|
||||
const repackSpy = jest.spyOn(instance, "masonryRepack");
|
||||
instance.masonryComponentReference.ref = undefined;
|
||||
instance.componentDidUpdate();
|
||||
expect(repackSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calling storeMasonryRef() saves the ref in local store", () => {
|
||||
const tree = ShallowAlertGrid();
|
||||
const instance = tree.instance();
|
||||
|
||||
Reference in New Issue
Block a user