Skip to content

Commit

Permalink
fix: createInterpolation test (#960)
Browse files Browse the repository at this point in the history
* fix: createInterpolation test

* fix test
  • Loading branch information
ssong10 authored Jul 8, 2024
1 parent 0a0d978 commit 3c18a58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ const pseudoHoverProp = createSystemProp({

describe('createInterpolation', () => {
const { theme } = useCurrentTheme();

const interpolation = createInterpolation([widthProp, heightProp, marginProp, pseudoHoverProp])({
theme,
breakpointIndex: 0,
});
const interpolation = createInterpolation([widthProp, heightProp, marginProp, pseudoHoverProp]);

let props: Record<string, any>;

Expand All @@ -55,7 +51,7 @@ describe('createInterpolation', () => {
});

it('systemProp return value is merged by media query key', () => {
expect(interpolation(props)).toStrictEqual({
expect(interpolation({ theme, props })).toStrictEqual({
width: 100,
height: 100,
'@media screen and (min-width: 640px)': {
Expand All @@ -72,7 +68,7 @@ describe('createInterpolation', () => {
});

it('should removed non-systemProp key', () => {
expect(interpolation(props)).toStrictEqual({ width: 100 });
expect(interpolation({ theme, props })).toStrictEqual({ width: 100 });
});
});

Expand All @@ -82,7 +78,7 @@ describe('createInterpolation', () => {
});

it('should return empty object', () => {
expect(interpolation(props)).toStrictEqual({});
expect(interpolation({ theme, props })).toStrictEqual({});
});
});

Expand All @@ -92,7 +88,7 @@ describe('createInterpolation', () => {
});

it('should return empty object', () => {
expect(interpolation(props)).toStrictEqual({});
expect(interpolation({ theme, props })).toStrictEqual({});
});
});
});
Expand All @@ -103,7 +99,7 @@ describe('createInterpolation', () => {
});

it('should return return value of all nested systemProp', () => {
expect(interpolation(props)).toStrictEqual({
expect(interpolation({ theme, props })).toStrictEqual({
'&:hover': { margin: 3 },
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMemo } from 'react';
import type { CurrentTheme } from '@vibrant-ui/theme';
import { isDefined, isRecord } from '@vibrant-ui/utils';
import type { SystemProp } from '../createSystemProp';
Expand Down Expand Up @@ -49,7 +48,7 @@ export const createInterpolation = (systemProps: SystemProp[], defaultProps: any
};

return ({ theme, props }: { theme: CurrentTheme; props: Record<string, any> }) => {
const interpolationResult = useMemo(() => childInterpolation({ ...defaultProps, ...props }, theme), [props, theme]);
const interpolationResult = childInterpolation({ ...defaultProps, ...props }, theme);

return useBuildStyle({ styleObjects: interpolationResult, theme });
};
Expand Down

0 comments on commit 3c18a58

Please sign in to comment.