Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce devMode to support nodejs based unit testing #946

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

zewa666
Copy link
Contributor

@zewa666 zewa666 commented Dec 7, 2023

as the title suggests this is meant to make unit/integration tests, e.g with testing-library, possible for apps using Slickgrid. In my specific case I'm making use of angular-slickgrid and would like to be able to test my app using angular-testing-library.

The introduced devMode workarounds are in order to work around the following jsdom issues:

jsdom/jsdom#2310 (missing clientWidth)
jsdom/jsdom#992 (missing ownerNode, even with a nice reference to Slickgrid ;) )
For additional conversations about this topic please refer to ghiscoding/Angular-Slickgrid#1319

@@ -108,6 +108,9 @@ export interface GridOption<C extends BaseColumn = BaseColumn> {
/** Default cell Formatter that will be used by the grid */
defaultFormatter?: Formatter;

/** Escape hatch geared towards testing Slickgrid in jsdom based environments to circumvent the lack of stylesheet.ownerNode and clientWidth calculations */
devMode?: false & { ownerNodeIndex?: number; containerClientWidth?: number; };
Copy link
Collaborator

@ghiscoding ghiscoding Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zewa666 isn't that supposed to be | instead of &, because it can never be both false and an object at the same time

Copy link
Contributor Author

@zewa666 zewa666 Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its an intersection, so a type being either false or object. with an union you'd get a compile error due to false and obj not sharing enough (false does not exist on type ...)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried it on my side and that worked with | but ok if you're sure then let's merge. Thanks for confirming. I'll copy that code to next slickgrid-universal too since I'll soon have my own slickgrid/dataview in my repo

@ghiscoding ghiscoding merged commit 918efa4 into 6pac:master Dec 7, 2023
2 checks passed
ghiscoding added a commit to ghiscoding/slickgrid-universal that referenced this pull request Dec 7, 2023
- copies implementation made in 6pac/SlickGrid repo at 6pac/SlickGrid#946
> as the title suggests this is meant to make unit/integration tests, e.g with testing-library, possible for apps using Slickgrid. In my specific case I'm making use of angular-slickgrid and would like to be able to test my app using angular-testing-library.
>
> The introduced devMode workarounds are in order to work around the following jsdom issues:
>
> [jsdom/jsdom#2310](jsdom/jsdom#2310) (missing clientWidth) [jsdom/jsdom#992](jsdom/jsdom#992) (missing ownerNode, even with a nice reference to Slickgrid ;) ) For additional conversations about this topic please refer to [ghiscoding/Angular-Slickgrid#1319](ghiscoding/Angular-Slickgrid#1319)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants