Skip to content

Commit 9079f0c

Browse files
committed
[#123] Modify tests
1 parent fb0cb72 commit 9079f0c

File tree

3 files changed

+112
-78
lines changed

3 files changed

+112
-78
lines changed

packages/eslint-plugin/lib/constants/test-data.js

Lines changed: 94 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -958,87 +958,103 @@ export const EXPORT_DEFAULT_함수형_컴포넌트 = {
958958
}
959959

960960
export const EMPTY_PROPS_COMPONENT = {
961-
컴포넌트_코드: `
962-
import {memo} from 'react';
963-
964-
const IconNPayTextShadow = () => (
965-
<svg width={width} height={height} viewBox={viewBox} style={style}>
966-
<g filter={\`url(#\${id})\`} fillRule="evenodd" clipRule="evenodd" fill="#fff">
967-
<path d="M24.612 7.554v2.97h1.632c1.079 0 1.734-.35 1.734-1.44v-.233c0-1.024-.655-1.297-1.593-1.297h-1.773zm-1.644-1.388h3.494c2.223 0 3.173 1.142 3.173 2.672v.272c0 1.518-1.027 2.814-3.173 2.814h-1.85v3.593h-1.644v-9.35zm11.7 6.278h-1.58c-.848 0-1.143.35-1.143.907v.156c0 .467.334.74.963.74.681 0 1.131-.143 1.465-.48.296-.286.296-.597.296-1.129v-.194zm-4.29 1.18v-.415c0-1.167.68-2.036 2.671-2.036h1.619V10.9c0-.882-.385-1.245-1.259-1.245-.758 0-1.413.246-2.004.713l-.797-1.193c.72-.506 1.606-.96 2.814-.96 1.657 0 2.852.843 2.852 2.283v5.018h-1.452l-.026-.881c-.27.635-1.271.985-2.017.985-1.516 0-2.402-.739-2.402-1.997zm10.01.025-1.606-5.278h-1.799l2.518 7.236-.912 2.348 1.516.531L43.78 8.371h-1.722l-1.619 5.278h-.051zM18.85 19H3V3h15.85v16zm-6.398-4h2.436V7h-2.552v4.282L9.398 7H6.963v8h2.551v-4.282L12.452 15z" />
968-
</g>
969-
<defs>
970-
<filter
971-
id={id}
972-
x="1"
973-
y="1"
974-
width="44.779"
975-
height="20"
976-
filterUnits="userSpaceOnUse"
977-
colorInterpolationFilters="sRGB">
978-
<feFlood floodOpacity="0" result="BackgroundImageFix" />
979-
<feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" />
980-
<feOffset />
981-
<feGaussianBlur stdDeviation="1" />
982-
<feComposite in2="hardAlpha" operator="out" />
983-
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0" />
984-
<feBlend in2="BackgroundImageFix" result="effect1_dropShadow_461_21739" />
985-
<feBlend in="SourceGraphic" in2="effect1_dropShadow_461_21739" result="shape" />
986-
</filter>
987-
</defs>
988-
</svg>
989-
);
961+
컴포넌트_코드: `import React from 'react'
962+
import * as CSS from 'csstype'
990963
991-
export default memo(IconNPayTextShadow);
992-
`,
993-
PROPS_없는_SVG_코드: `
994-
<svg width="width" height="height" viewBox="viewBox" style="style">
995-
<g filter="url(#id)" fillRule="evenodd" clipRule="evenodd" fill="#fff">
996-
<path d="M24.612 7.554v2.97h1.632c1.079 0 1.734-.35 1.734-1.44v-.233c0-1.024-.655-1.297-1.593-1.297h-1.773zm-1.644-1.388h3.494c2.223 0 3.173 1.142 3.173 2.672v.272c0 1.518-1.027 2.814-3.173 2.814h-1.85v3.593h-1.644v-9.35zm11.7 6.278h-1.58c-.848 0-1.143.35-1.143.907v.156c0 .467.334.74.963.74.681 0 1.131-.143 1.465-.48.296-.286.296-.597.296-1.129v-.194zm-4.29 1.18v-.415c0-1.167.68-2.036 2.671-2.036h1.619V10.9c0-.882-.385-1.245-1.259-1.245-.758 0-1.413.246-2.004.713l-.797-1.193c.72-.506 1.606-.96 2.814-.96 1.657 0 2.852.843 2.852 2.283v5.018h-1.452l-.026-.881c-.27.635-1.271.985-2.017.985-1.516 0-2.402-.739-2.402-1.997zm10.01.025-1.606-5.278h-1.799l2.518 7.236-.912 2.348 1.516.531L43.78 8.371h-1.722l-1.619 5.278h-.051zM18.85 19H3V3h15.85v16zm-6.398-4h2.436V7h-2.552v4.282L9.398 7H6.963v8h2.551v-4.282L12.452 15z" />
997-
</g>
998-
<defs>
999-
<filter
1000-
id="id"
1001-
x="1"
1002-
y="1"
1003-
width="44.779"
1004-
height="20"
1005-
filterUnits="userSpaceOnUse"
1006-
colorInterpolationFilters="sRGB">
1007-
<feFlood floodOpacity="0" result="BackgroundImageFix" />
1008-
<feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" />
1009-
<feOffset />
1010-
<feGaussianBlur stdDeviation="1" />
1011-
<feComposite in2="hardAlpha" operator="out" />
1012-
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0" />
1013-
<feBlend in2="BackgroundImageFix" result="effect1_dropShadow_461_21739" />
1014-
<feBlend in="SourceGraphic" in2="effect1_dropShadow_461_21739" result="shape" />
1015-
</filter>
1016-
</defs>
964+
export default function IconExample() {
965+
return (
966+
<svg width="100%" height="100%" viewBox="0 0 9 18" style="">
967+
<path
968+
fill="none"
969+
fillRule="evenodd"
970+
stroke="#000"
971+
strokeLinejoin="round"
972+
d="M8.521 0L0.5 8.021 8.521 16"
973+
transform="translate(0 1)"
974+
/>
975+
</svg>
976+
)
977+
}`,
978+
PROPS: {},
979+
PROPS_없는_SVG_코드: `<svg width="100%" height="100%" viewBox="0 0 9 18" style="">
980+
<path
981+
fill="none"
982+
fillRule="evenodd"
983+
stroke="#000"
984+
strokeLinejoin="round"
985+
d="M8.521 0L0.5 8.021 8.521 16"
986+
transform="translate(0 1)"
987+
/>
1017988
</svg>`,
989+
/**
990+
* props가 없는 경우 동적으로 변경되는 값이 없으므로 그대로 유지
991+
*/
992+
완료된_SVG_코드: `<svg width="100%" height="100%" viewBox="0 0 9 18">
993+
<path
994+
fill="none"
995+
fillRule="evenodd"
996+
stroke="#000"
997+
strokeLinejoin="round"
998+
d="M8.521 0L0.5 8.021 8.521 16"
999+
transform="translate(0 1)"
1000+
/>
1001+
</svg>`,
1002+
}
1003+
1004+
export const EMPTY_CONTAINER_COMPONENT = {
1005+
컴포넌트_코드: `import React from 'react'
1006+
import * as CSS from 'csstype'
1007+
1008+
export default function IconExample() {
1009+
return (
1010+
<svg width="100%" height="100%" viewBox="0 0 9 18" style="">
1011+
<g>
1012+
<g>
1013+
<path
1014+
fill="none"
1015+
fillRule="evenodd"
1016+
stroke="#000"
1017+
strokeLinejoin="round"
1018+
d="M8.521 0L0.5 8.021 8.521 16"
1019+
transform="translate(0 1)"
1020+
/>
1021+
</g>
1022+
</g>
1023+
<path />
1024+
<path />
1025+
<path />
1026+
</svg>
1027+
)
1028+
}`,
10181029
PROPS: {},
1019-
완료된_SVG_코드: `
1020-
<svg width={width} height={height} viewBox={viewBox} style={style}>
1021-
<g filter={\`url(#\${id})\`} fillRule="evenodd" clipRule="evenodd" fill="#fff">
1022-
<path d="M24.612 7.554v2.97h1.632c1.079 0 1.734-.35 1.734-1.44v-.233c0-1.024-.655-1.297-1.593-1.297h-1.773zm-1.644-1.388h3.494c2.223 0 3.173 1.142 3.173 2.672v.272c0 1.518-1.027 2.814-3.173 2.814h-1.85v3.593h-1.644v-9.35zm11.7 6.278h-1.58c-.848 0-1.143.35-1.143.907v.156c0 .467.334.74.963.74.681 0 1.131-.143 1.465-.48.296-.286.296-.597.296-1.129v-.194zm-4.29 1.18v-.415c0-1.167.68-2.036 2.671-2.036h1.619V10.9c0-.882-.385-1.245-1.259-1.245-.758 0-1.413.246-2.004.713l-.797-1.193c.72-.506 1.606-.96 2.814-.96 1.657 0 2.852.843 2.852 2.283v5.018h-1.452l-.026-.881c-.27.635-1.271.985-2.017.985-1.516 0-2.402-.739-2.402-1.997zm10.01.025-1.606-5.278h-1.799l2.518 7.236-.912 2.348 1.516.531L43.78 8.371h-1.722l-1.619 5.278h-.051zM18.85 19H3V3h15.85v16zm-6.398-4h2.436V7h-2.552v4.282L9.398 7H6.963v8h2.551v-4.282L12.452 15z" />
1030+
PROPS_없는_SVG_코드: `<svg width="100%" height="100%" viewBox="0 0 9 18" style="">
1031+
<g>
1032+
<g>
1033+
<path
1034+
fill="none"
1035+
fillRule="evenodd"
1036+
stroke="#000"
1037+
strokeLinejoin="round"
1038+
d="M8.521 0L0.5 8.021 8.521 16"
1039+
transform="translate(0 1)"
1040+
/>
1041+
</g>
10231042
</g>
1024-
<defs>
1025-
<filter
1026-
id={id}
1027-
x="1"
1028-
y="1"
1029-
width="44.779"
1030-
height="20"
1031-
filterUnits="userSpaceOnUse"
1032-
colorInterpolationFilters="sRGB">
1033-
<feFlood floodOpacity="0" result="BackgroundImageFix" />
1034-
<feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" />
1035-
<feOffset />
1036-
<feGaussianBlur stdDeviation="1" />
1037-
<feComposite in2="hardAlpha" operator="out" />
1038-
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0" />
1039-
<feBlend in2="BackgroundImageFix" result="effect1_dropShadow_461_21739" />
1040-
<feBlend in="SourceGraphic" in2="effect1_dropShadow_461_21739" result="shape" />
1041-
</filter>
1042-
</defs>
1043+
<path />
1044+
<path />
1045+
<path />
1046+
</svg>`,
1047+
/**
1048+
* props가 없는 경우 동적으로 변경되는 값이 없으므로 그대로 유지
1049+
*/
1050+
완료된_SVG_코드: `<svg width="100%" height="100%" viewBox="0 0 9 18">
1051+
<path
1052+
fill="none"
1053+
fillRule="evenodd"
1054+
stroke="#000"
1055+
strokeLinejoin="round"
1056+
d="M8.521 0L0.5 8.021 8.521 16"
1057+
transform="translate(0 1)"
1058+
/>
10431059
</svg>`,
10441060
}

packages/eslint-plugin/lib/utils/svg/props.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
함수형_컴포넌트,
1313
EXPORT_DEFAULT_함수형_컴포넌트,
1414
EMPTY_PROPS_COMPONENT,
15+
EMPTY_CONTAINER_COMPONENT,
1516
} from '../../constants/test-data'
1617
import {trimAll} from '../string'
1718
import {extractPropsFromLiteralCode} from './props'
@@ -37,6 +38,7 @@ describe('extractComponentProps', () => {
3738
[함수형_컴포넌트.컴포넌트_코드, 함수형_컴포넌트.PROPS],
3839
[EXPORT_DEFAULT_함수형_컴포넌트.컴포넌트_코드, EXPORT_DEFAULT_함수형_컴포넌트.PROPS],
3940
[EMPTY_PROPS_COMPONENT.컴포넌트_코드, EMPTY_PROPS_COMPONENT.PROPS],
41+
[EMPTY_CONTAINER_COMPONENT.컴포넌트_코드, EMPTY_CONTAINER_COMPONENT.PROPS],
4042
])('ast tree에서 props를 추출한다.', (code, expectedProps) => {
4143
const scope = parseCode(code)
4244

packages/eslint-plugin/lib/utils/svg/transform.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
PROPS_변수_컴포넌트,
1010
함수형_컴포넌트,
1111
EXPORT_DEFAULT_함수형_컴포넌트,
12+
EMPTY_PROPS_COMPONENT,
13+
EMPTY_CONTAINER_COMPONENT,
1214
} from '../../constants/test-data'
1315
import {trimAll} from '../string'
1416
import {svgoOptimize} from './transform'
@@ -95,6 +97,20 @@ describe('transform', () => {
9597
EXPORT_DEFAULT_함수형_컴포넌트.완료된_SVG_코드,
9698
undefined,
9799
],
100+
[
101+
'EMPTY_PROPS_COMPONENT',
102+
EMPTY_PROPS_COMPONENT.PROPS_없는_SVG_코드,
103+
EMPTY_PROPS_COMPONENT.PROPS,
104+
EMPTY_PROPS_COMPONENT.완료된_SVG_코드,
105+
undefined,
106+
],
107+
[
108+
'EMPTY_CONTAINER_COMPONENT',
109+
EMPTY_CONTAINER_COMPONENT.PROPS_없는_SVG_코드,
110+
EMPTY_CONTAINER_COMPONENT.PROPS,
111+
EMPTY_CONTAINER_COMPONENT.완료된_SVG_코드,
112+
undefined,
113+
],
98114
])('[%s] 정상적으로 svg transformation을 수행한다.', (_, svgCode, props, result, exceptAttr) => {
99115
const data = svgoOptimize({svgCode, props, exceptAttr})
100116

0 commit comments

Comments
 (0)