Skip to content

Commit df004ab

Browse files
authored
chore: more refs (#63)
* chore: more refs * test: more test
1 parent b32f8f8 commit df004ab

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/CSSMotion.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import { getTransitionName, supportTransition } from './util/motion';
1818

1919
export interface CSSMotionRef {
2020
nativeElement: HTMLElement;
21-
inMotion: () => boolean;
21+
inMotion: boolean;
22+
enableMotion: boolean;
2223
}
2324

2425
export type CSSMotionConfig =
@@ -172,9 +173,11 @@ export function genCSSMotion(config: CSSMotionConfig) {
172173
},
173174
inMotion: {
174175
enumerable: true,
175-
get: () => {
176-
return () => getStatus() !== STATUS_NONE;
177-
},
176+
get: () => getStatus() !== STATUS_NONE,
177+
},
178+
enableMotion: {
179+
enumerable: true,
180+
get: () => supportMotion,
178181
},
179182
});
180183
return obj;

tests/StrictMode.spec.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,24 @@ describe('StrictMode', () => {
4343
</React.StrictMode>,
4444
);
4545

46+
expect(ref.current.enableMotion).toBeTruthy();
47+
4648
const node = container.querySelector('.motion-box');
4749
expect(node).toHaveClass('transition-appear', 'transition-appear-start');
4850

4951
// Active
5052
act(() => {
5153
jest.runAllTimers();
5254
});
53-
expect(ref.current.inMotion()).toBeTruthy();
55+
expect(ref.current.inMotion).toBeTruthy();
5456
expect(node).not.toHaveClass('transition-appear-start');
5557
expect(node).toHaveClass('transition-appear-active');
5658

5759
// Trigger End
5860
fireEvent.transitionEnd(node);
5961
expect(node).not.toHaveClass('transition-appear');
6062

61-
expect(ref.current.inMotion()).toBeFalsy();
63+
expect(ref.current.inMotion).toBeFalsy();
6264
expect(ref.current.nativeElement).toBe(node);
6365
});
6466
});

0 commit comments

Comments
 (0)