Skip to content

Commit

Permalink
Fix shimmer test (#3318)
Browse files Browse the repository at this point in the history
* Fix shimmer test

* Change files
  • Loading branch information
rurikoaraki authored Dec 19, 2023
1 parent d8673aa commit f47e1b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Fix shimmer test",
"packageName": "@fluentui-react-native/experimental-shimmer",
"email": "[email protected]",
"dependentChangeType": "patch"
}
9 changes: 6 additions & 3 deletions packages/experimental/Shimmer/src/Shimmer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import * as renderer from 'react-test-renderer';
import { Shimmer } from './Shimmer';
import type { ShimmerCircleElement, ShimmerRectElement } from './Shimmer.types';

// mocks out setTimeout and other timer functions with mock functions, test will fail without this as we're using Animated API
jest.useFakeTimers();

function shimmerRects(): Array<ShimmerRectElement | ShimmerCircleElement> {
return [
{
Expand Down Expand Up @@ -43,6 +40,12 @@ function shimmerRects(): Array<ShimmerRectElement | ShimmerCircleElement> {
const style = { width: 300, height: 100 };

describe('Shimmer component tests', () => {
beforeAll(() => {
// mocks out setTimeout and other timer functions with mock functions, test will fail without this as we're using Animated API
jest.useFakeTimers();
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
});

it('Shimmer default', async () => {
const tree = renderer.create(<Shimmer elements={shimmerRects()} />).toJSON();
expect(tree).toMatchSnapshot();
Expand Down

0 comments on commit f47e1b2

Please sign in to comment.