Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/button,icon,typography prop업데이트 #56

Merged
merged 18 commits into from
Jul 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9e9ce58
:lipstick: delete margin-bottoms in typography-heading
Hemistone Jul 21, 2021
7a9a8ea
:white_check_mark: update stories snap
Hemistone Jul 22, 2021
2daa8a9
:fire: remove touchable on Icon, Icon tests / edit style on touchable…
Hemistone Jul 22, 2021
1b1ef58
:white_check_mark: Icon Unit Test에서 touchable 관련 요소 삭제, 겹치는 테스트 케이스 삭제
Hemistone Jul 22, 2021
a02f005
:sparkles: Icon size prop 추가
Hemistone Jul 22, 2021
281c7de
:white_check_mark: Icon size에 대한 stories 업데이트 및 Size 섹션 추가
Hemistone Jul 22, 2021
b8d7272
:white_check_mark: Storybook Icon Playground Size prop 테스트 추가
Hemistone Jul 22, 2021
5de6d97
:sparkles: Button prop 변경 및 storybook 업데이트
Hemistone Jul 22, 2021
67b3be4
:white_check_mark: Button Unit Test disabled, loading 테스트 완성
Hemistone Jul 22, 2021
a7853cf
:white_check_mark: Icon CustomStyle Storybook 테스크 코드 추가
Hemistone Jul 22, 2021
701fd6c
:bug: Button에 기본으로 sm 사이즈 아이콘 적용, snapshot 업데이트
Hemistone Jul 22, 2021
1b1b229
:twisted_rightwards_arrows: Merge remote-tracking branch 'origin/deve…
Hemistone Jul 23, 2021
9c198a2
:bug: LoadingDots 적용, 불필요한 Button내 IconProps 제거
Hemistone Jul 23, 2021
01645fd
:white_check_mark: Storybook snapshot 업데이트
Hemistone Jul 23, 2021
be92cde
:fire: buttoncolors.ts파일 주석 삭제
Hemistone Jul 23, 2021
be82736
:art: Icon, Button default 값에 대한 case handling 추가
Hemistone Jul 23, 2021
b56a5ba
:white_check_mark: Button Unit Test 코드 업데이트트
Hemistone Jul 23, 2021
bfcf6c9
:ambulance: Update grayscale colors correctly in Button test code
Hemistone Jul 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified src/assets/fonts/NotoSansKR-Black.otf
100755 → 100644
Empty file.
Empty file modified src/assets/fonts/NotoSansKR-Bold.otf
100755 → 100644
Empty file.
Empty file modified src/assets/fonts/NotoSansKR-Light.otf
100755 → 100644
Empty file.
Empty file modified src/assets/fonts/NotoSansKR-Medium.otf
100755 → 100644
Empty file.
Empty file modified src/assets/fonts/NotoSansKR-Regular.otf
100755 → 100644
Empty file.
Empty file modified src/assets/fonts/NotoSansKR-Thin.otf
100755 → 100644
Empty file.
321 changes: 249 additions & 72 deletions src/atoms/Button/Button.stories.tsx

Large diffs are not rendered by default.

140 changes: 140 additions & 0 deletions src/atoms/Button/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import 'jest-styled-components';
import React from 'react';
import Button from './Button';
import { shallow } from 'enzyme';
import { systemColors } from '../../styles/system-colors';
import { buttonTouchedColors } from './buttonColors';
import { grayscaleColors } from '../../styles/grayscale-colors';

describe('[Button] Unit Test', () => {
it('should fire onPress event', () => {
Expand All @@ -18,4 +21,141 @@ describe('[Button] Unit Test', () => {
button.simulate('press');
expect(onPressMock).toHaveBeenCalledTimes(1);
});
it('should not fire onPress event when disabled', () => {
const onPressMock = jest.fn();
const textMock = 'test';
const button = shallow(
<Button disabled onPress={onPressMock}>
{textMock}
</Button>,
);
button.simulate('press');
expect(onPressMock).toHaveBeenCalledTimes(0);
});
it('should not fire onPress event when loading', () => {
const onPressMock = jest.fn();
const textMock = 'test';
const button = shallow(
<Button loading onPress={onPressMock}>
{textMock}
</Button>,
);
button.simulate('press');
expect(onPressMock).toHaveBeenCalledTimes(0);
});
it('should not fire onPress event when loading and disabled', () => {
const onPressMock = jest.fn();
const textMock = 'test';
const button = shallow(
<Button loading disabled onPress={onPressMock}>
{textMock}
</Button>,
);
button.simulate('press');
expect(onPressMock).toHaveBeenCalledTimes(0);
});
it('should show corresponding colors on pressed state', () => {
const onPressMock = jest.fn();
const textMock = 'test';
const button = shallow(
<Button
color={systemColors.PRIMARY}
onPress={onPressMock}
icon={require('../../assets/icons/shop/shop.png')}
>
{textMock}
</Button>,
);
const container = shallow(button.props().children(true));
const buttonText = container.find('ButtonText');
const buttonIcon = container.find('ButtonIcon');

const containerProps = container.props() as {
containerTouchedColor?: string;
};

const buttonTextProps = buttonText.props() as { textColor?: string };
const buttonIconProps = buttonIcon.props() as { color?: string };

expect(containerProps.containerTouchedColor).toBe(
buttonTouchedColors[systemColors.PRIMARY],
);
expect(buttonTextProps.textColor).toBe(systemColors.WHITE);
expect(buttonIconProps.color).toBe(systemColors.WHITE);
});
it('should show fixed color on pressed state if touchedColor is set', () => {
const onPressMock = jest.fn();
const textMock = 'test';
const button = shallow(
<Button
color={systemColors.PRIMARY}
onPress={onPressMock}
touchedColor={systemColors.SUCCESS}
icon={require('../../assets/icons/shop/shop.png')}
>
{textMock}
</Button>,
);
const container = shallow(button.props().children(true));
const buttonText = container.find('ButtonText');
const buttonIcon = container.find('ButtonIcon');

const containerProps = container.props() as {
containerTouchedColor?: string;
};

const buttonTextProps = buttonText.props() as { textColor?: string };
const buttonIconProps = buttonIcon.props() as { color?: string };

expect(containerProps.containerTouchedColor).toBe(systemColors.SUCCESS);
expect(buttonTextProps.textColor).toBe(systemColors.WHITE);
expect(buttonIconProps.color).toBe(systemColors.WHITE);
});
it('should show grayscale color as touchedColor if type is text', () => {
const onPressMock = jest.fn();
const textMock = 'test';
const button = shallow(
<Button
type="text"
color={systemColors.PRIMARY}
onPress={onPressMock}
icon={require('../../assets/icons/shop/shop.png')}
>
{textMock}
</Button>,
);
const container = shallow(button.props().children(true));

const containerProps = container.props() as {
containerTouchedColor?: string;
};

expect(containerProps.containerTouchedColor).toBe(grayscaleColors.GRAY_100);
});

it('should show icon color with prop color if type is text', () => {
const onPressMock = jest.fn();
const textMock = 'test';
const button = shallow(
<Button
type="text"
color={systemColors.PRIMARY}
onPress={onPressMock}
icon={require('../../assets/icons/shop/shop.png')}
>
{textMock}
</Button>,
);
const container = shallow(button.props().children(true));
const buttonIcon = container.find('ButtonIcon');

const containerProps = container.props() as {
containerTouchedColor?: string;
};

const buttonIconProps = buttonIcon.props() as { color?: string };

expect(containerProps.containerTouchedColor).toBe(grayscaleColors.GRAY_100);
expect(buttonIconProps.color).toBe(systemColors.PRIMARY);
});
});
Loading