Skip to content

Commit

Permalink
chore: fix node 16 react unit tests
Browse files Browse the repository at this point in the history
relates to vmware-clarity#23

Signed-off-by: Ashley Ryan <asryan@vmware.com>
  • Loading branch information
Ashley Ryan committed Apr 27, 2022
1 parent e1665ac commit b2b2a4e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions projects/core/src/internal/decorators/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ import {
PRIVATE_ANIMATION_STATUS_ATTR_NAME,
} from '../motion/interfaces.js';
import { runPropertyAnimations } from '../motion/utils.js';
import { isJestTest } from '../utils/environment.js';

// decorator factory that extends the component constructor to inject animations code into it
export function animate(config: PropertyDrivenAnimation) {
if (isJestTest()) {
return function () {
// jsdom doesn't like the class returned from the decorator below
// do nothing
};
}

// eslint-disable-next-line @typescript-eslint/ban-types
return function _animationDecorator<T extends { new (...args: any[]): AnimatableElement }>(constructor: T) {
return class extends constructor {
Expand Down
15 changes: 15 additions & 0 deletions projects/react/src/accordion/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ exports[`CdsAccordion snapshot 1`] = `
Content 1
</cds-accordion-content>
</cds-accordion-panel>
<cds-accordion-panel>
<cds-accordion-header
id="my-header-2"
slot="accordion-header"
>
Item 2
</cds-accordion-header>
<cds-accordion-content
id="my-content-2"
role="region"
slot="accordion-content"
>
Content 2
</cds-accordion-content>
</cds-accordion-panel>
</cds-accordion>
</div>
`;
4 changes: 4 additions & 0 deletions projects/react/src/accordion/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ describe('CdsAccordion', () => {
<CdsAccordionHeader id="my-header">Item 1</CdsAccordionHeader>
<CdsAccordionContent id="my-content">Content 1</CdsAccordionContent>
</CdsAccordionPanel>
<CdsAccordionPanel>
<CdsAccordionHeader id="my-header-2">Item 2</CdsAccordionHeader>
<CdsAccordionContent id="my-content-2">Content 2</CdsAccordionContent>
</CdsAccordionPanel>
</CdsAccordion>
);
expect(container).toMatchSnapshot();
Expand Down

0 comments on commit b2b2a4e

Please sign in to comment.