Skip to content

Commit

Permalink
Update tests: onInteraction is no longer called when props change
Browse files Browse the repository at this point in the history
  • Loading branch information
ab-pm committed May 15, 2024
1 parent ad16924 commit 22355c2
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions packages/core/test/popover/popoverTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -455,36 +455,25 @@ describe("<Popover>", () => {
renderPopover({ disabled: true, isOpen: true }).assertIsOpen(false);
});

it("onInteraction not called if changing from closed to open (b/c popover is still closed)", () => {
it("when changing from closed to open", () => {
renderPopover({ disabled: true, isOpen: false, onInteraction: onInteractionSpy })
.assertOnInteractionCalled(false)
.setProps({ isOpen: true })
.assertIsOpen(false)
.assertOnInteractionCalled(false);
});

it("onInteraction not called if changing from open to closed (b/c popover was already closed)", () => {
renderPopover({ disabled: true, isOpen: true, onInteraction: onInteractionSpy })
.assertOnInteractionCalled(false)
.setProps({ isOpen: false })
.assertOnInteractionCalled(false);
.setProps({ isOpen: true })
.assertIsOpen(false);
});

it("onInteraction called if open and changing to disabled (b/c popover will close)", () => {
it("when changing open to disabled (so popover will close)", () => {
renderPopover({ disabled: false, isOpen: true, onInteraction: onInteractionSpy })
.assertIsOpen()
.assertOnInteractionCalled(false)
.setProps({ disabled: true })
.assertOnInteractionCalled();
.assertIsOpen(false);
});

it("onInteraction called if open and changing to not-disabled (b/c popover will open)", () => {
it("when changing open to not-disabled (so popover will open)", () => {
renderPopover({ disabled: true, isOpen: true, onInteraction: onInteractionSpy })
.assertOnInteractionCalled(false)
.assertIsOpen(false)
.setProps({ disabled: false })
.update()
.assertIsOpen()
.assertOnInteractionCalled();
.assertIsOpen();
});
});

Expand Down Expand Up @@ -649,7 +638,6 @@ describe("<Popover>", () => {
.simulateTarget("click")
.assertIsOpen()
.setProps({ disabled: true })
.update()
.assertIsOpen(false);
});

Expand Down Expand Up @@ -881,7 +869,6 @@ describe("<Popover>", () => {
targetButton: HTMLButtonElement;
assertFindClass(className: string, expected?: boolean, msg?: string): this;
assertIsOpen(isOpen?: boolean): this;
assertOnInteractionCalled(called?: boolean): this;
simulateContent(eventName: string, ...args: any[]): this;
/** Careful: simulating "focus" is unsupported by Enzyme, see https://stackoverflow.com/a/56892875/7406866 */
simulateTarget(eventName: string, ...args: any[]): this;
Expand Down Expand Up @@ -925,10 +912,6 @@ describe("<Popover>", () => {
assert.equal(overlay.prop("isOpen"), isOpen, "PopoverWrapper#assertIsOpen()");
return wrapper!;
};
wrapper.assertOnInteractionCalled = (called = true) => {
assert.strictEqual(onInteractionSpy.called, called, "PopoverWrapper#assertOnInteractionCalled()");
return wrapper!;
};
wrapper.findClass = (className: string) => wrapper!.find(`.${className}`).hostNodes();
wrapper.simulateContent = (eventName: string, ...args) => {
wrapper!.findClass("test-content").simulate(eventName, ...args);
Expand Down

0 comments on commit 22355c2

Please sign in to comment.