Skip to content

Commit

Permalink
test getShadow (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlucas authored Jun 17, 2023
1 parent b4adfdf commit 05790ae
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
37 changes: 37 additions & 0 deletions src/native/__tests__/getShadow.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { defaultShadowProps, getShadow } from '../getShadow';

describe('getShadow', () => {
it('should return default options', () => {
const shadowMock = `
shadow-offset: ${defaultShadowProps.xOffset}px ${defaultShadowProps.yOffset}px;
shadow-opacity: ${defaultShadowProps.shadowOpacity};
shadow-radius: ${defaultShadowProps.shadowRadius}px;
shadow-color: ${defaultShadowProps.shadowColor};
elevation: ${defaultShadowProps.elevation};
`;
const shadow = getShadow();

expect(shadow.replace(/\s/g, '')).toBe(shadowMock.replace(/\s/g, ''));
});

it('should return shadow with another options', () => {
const shadowOptions = {
xOffset: 1,
yOffset: 2,
shadowRadius: 6,
shadowOpacity: 0.7,
shadowColor: '#FFF',
elevation: 1,
};
const shadowMock = `
shadow-offset: ${shadowOptions.xOffset}px ${shadowOptions.yOffset}px;
shadow-opacity: ${shadowOptions.shadowOpacity};
shadow-radius: ${shadowOptions.shadowRadius}px;
shadow-color: ${shadowOptions.shadowColor};
elevation: ${shadowOptions.elevation};
`;
const shadow = getShadow(shadowOptions);

expect(shadow.replace(/\s/g, '')).toBe(shadowMock.replace(/\s/g, ''));
});
});
14 changes: 8 additions & 6 deletions src/native/getShadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ export const defaultShadowProps = {
elevation: 3,
};

export const getShadow = (defaultShadowProps: GetShadowType = {}): string => `
shadow-offset: ${defaultShadowProps.xOffset}px ${defaultShadowProps.yOffset}px;
shadow-opacity: ${defaultShadowProps.shadowOpacity};
shadow-radius: ${defaultShadowProps.shadowRadius}px;
shadow-color: ${defaultShadowProps.shadowColor};
elevation: ${defaultShadowProps.elevation};
export const getShadow = (
shadowOptions: GetShadowType = defaultShadowProps,
): string => `
shadow-offset: ${shadowOptions.xOffset}px ${shadowOptions.yOffset}px;
shadow-opacity: ${shadowOptions.shadowOpacity};
shadow-radius: ${shadowOptions.shadowRadius}px;
shadow-color: ${shadowOptions.shadowColor};
elevation: ${shadowOptions.elevation};
`;

0 comments on commit 05790ae

Please sign in to comment.