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

feat(tag, theme)!: update colored tag variant #758

Merged
merged 66 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
c6406aa
chore(tag): adds color types
hebernardEquisoft Feb 28, 2024
3e0ba62
chore(tag): v1
hebernardEquisoft Mar 1, 2024
b7806a3
chore(tag): update
hebernardEquisoft Mar 1, 2024
5d176c4
chore(tag): update spacing
hebernardEquisoft Mar 4, 2024
94259ff
chore(tag): update tokens
hebernardEquisoft Mar 4, 2024
c41de66
Merge branch 'master' into dev/DS-948
hebernardEquisoft Mar 4, 2024
3697532
fix(tag): stylelint
hebernardEquisoft Mar 4, 2024
a4760a8
fix(tag): update snapshots
hebernardEquisoft Mar 4, 2024
f5da602
fix(storybook): dependencies
hebernardEquisoft Mar 4, 2024
da4eb51
fix(stroybook): revert dependencies
hebernardEquisoft Mar 4, 2024
eaa3f00
fix(storybook): dependencies
hebernardEquisoft Mar 4, 2024
14a9aae
fix(tag): post review changes
hebernardEquisoft Mar 4, 2024
437e095
fix(tag): update snapshots
hebernardEquisoft Mar 4, 2024
5358a42
fix(storybook): dependencies
hebernardEquisoft Mar 4, 2024
58e97fd
Merge branch 'master' into dev/DS-948
hebernardEquisoft Mar 11, 2024
7864ca4
fix(tag, theme): remove default predefined colors
hebernardEquisoft Mar 11, 2024
9dccc3c
Merge branch 'master' into dev/DS-948
hebernardEquisoft Mar 11, 2024
2446c32
fix(tag, theme): post design review
hebernardEquisoft Mar 12, 2024
1ca74c4
Merge branch 'master' into dev/DS-948
hebernardEquisoft Mar 12, 2024
7e43c99
fix(tag, theme): snapshots
hebernardEquisoft Mar 12, 2024
e2a503c
fix(tag): make color priority minimal
hebernardEquisoft Mar 12, 2024
1f57aef
fix(tag): post review changes
hebernardEquisoft Mar 12, 2024
d78a34c
fix(tag): post review changes
hebernardEquisoft Mar 13, 2024
861d815
Merge branch 'master' into dev/DS-948
hebernardEquisoft Mar 18, 2024
b689ee9
fix(tag): post review changes
hebernardEquisoft Mar 18, 2024
4119f74
fix(tag): remove extra label
hebernardEquisoft Mar 19, 2024
37e9327
Merge branch 'master' into dev/DS-948
hebernardEquisoft Mar 19, 2024
ed8dd6a
Merge branch 'master' into dev/DS-948
hebernardEquisoft Mar 19, 2024
6e1f0cc
fix(tag): post review changes
hebernardEquisoft Mar 19, 2024
0627717
fix(tag): post review changes
hebernardEquisoft Mar 20, 2024
5ba6531
fix(tag): update snapshots
hebernardEquisoft Mar 20, 2024
4f82c7c
fix(tag): update tests
hebernardEquisoft Mar 20, 2024
5c62db3
Merge branch 'master' into dev/DS-948
hebernardEquisoft Mar 20, 2024
685a020
fix(tag): post review changes
hebernardEquisoft Mar 21, 2024
4da2907
Merge branch 'master' into dev/DS-948
hebernardEquisoft Mar 27, 2024
e5722fb
fix(tag): remove redundant tokens
hebernardEquisoft Apr 1, 2024
8f85374
Merge branch 'master' into dev/DS-948
hebernardEquisoft Apr 1, 2024
0804f14
fix(tag): remove redundant tokens
hebernardEquisoft Apr 1, 2024
02490e6
fix(tag): add necessary token
hebernardEquisoft Apr 1, 2024
971679f
fix(tag): update icon colors
hebernardEquisoft Apr 1, 2024
4889409
fix(tag): update snapshots
hebernardEquisoft Apr 1, 2024
213c6ce
fix(tag): post review changes
hebernardEquisoft Apr 1, 2024
badb997
fix(tag): merge master
hebernardEquisoft Apr 2, 2024
dc79313
Revert "chore(deps): update yarn minors and patches (#766)"
hebernardEquisoft Apr 4, 2024
588db5c
fix(tag): update tag structure
hebernardEquisoft Apr 11, 2024
437b407
fix(tag): update snapshots
hebernardEquisoft Apr 11, 2024
862cc26
Merge branch 'master' into dev/DS-948
hebernardEquisoft Apr 11, 2024
30e664a
fix(tag): yarn install
hebernardEquisoft Apr 11, 2024
b9631b8
fix(tag): remove unused token
hebernardEquisoft Apr 11, 2024
a9bb897
fix(tag): docgen patch
hebernardEquisoft Apr 11, 2024
eed9270
fix(tag): post review changes
hebernardEquisoft Apr 16, 2024
bf38b59
Merge branch 'master' into dev/DS-948
hebernardEquisoft Apr 16, 2024
4aaf01d
fix(tag): update yarn lock
hebernardEquisoft Apr 16, 2024
719d48a
fix(tag): revert storybook package changes
hebernardEquisoft Apr 16, 2024
9928707
fix(tag): post review changes
hebernardEquisoft Apr 16, 2024
5ba41fe
fix(tag): post review changes
hebernardEquisoft Apr 16, 2024
11103f2
fix(tag): post review changes
hebernardEquisoft Apr 16, 2024
c0bccf8
fix(tag): post review changes
hebernardEquisoft Apr 16, 2024
c4333c5
fix(tag): eslint
hebernardEquisoft Apr 16, 2024
aa06a2b
fix(tag): post review changes
hebernardEquisoft Apr 16, 2024
2bafbe4
fix(tag): yarn lock
hebernardEquisoft Apr 16, 2024
2334013
fix(tag): yarn lock from master
hebernardEquisoft Apr 16, 2024
f484020
fix(tag): remove unecessary exports
hebernardEquisoft Apr 16, 2024
f0a56ea
fix(tag): post review changes
hebernardEquisoft Apr 24, 2024
f08e67f
Merge branch 'master' into dev/DS-948
hebernardEquisoft Apr 24, 2024
f0ac0d5
fix(tag): post merge master changes
hebernardEquisoft Apr 24, 2024
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
158 changes: 75 additions & 83 deletions packages/react/src/components/tag/tag.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,98 +6,90 @@ import { Tag, TagProps } from './tag';

describe('Tag', () => {
const tagSizes: TagProps['size'][] = ['small', 'medium'];
tagSizes.forEach((size) => {
describe(`Tag ${size}`, () => {
it('should call onClick callback when tag is clicked', () => {
const callback = jest.fn();
const wrapper = shallow(
<Tag size={size} value={{ label: 'Test' }} onClick={callback} />,
);

wrapper.simulate('click');

expect(callback).toHaveBeenCalledTimes(1);
});

it('should call onDelete callback when delete-button is clicked', () => {
const callback = jest.fn();
const stopPropagation = jest.fn();
const wrapper = shallow(
<Tag size={size} value={{ label: 'Test' }} onDelete={callback} />,
);

getByTestId(wrapper, 'Test-delete-button').simulate('click', { stopPropagation });

expect(callback).toHaveBeenCalledTimes(1);
});

it(
'should have aria-hidden="false" and an aria-label on icon when the label is not the same as iconName',
() => {
const wrapper = shallow(
<Tag size={size} iconName="home" value={{ label: 'Test' }} />,
);

const testIconWrapper = getByTestId(wrapper, 'Test-icon');
expect(testIconWrapper.prop('aria-label')).toBe('home');
expect(testIconWrapper.prop('aria-hidden')).toBe(false);
},
);
const tagColors: TagProps['color'][] = ['default', 'decorative-01', 'decorative-02'];

it(
'should have aria-hidden="true" and no label on icon when the label is the same as the iconName',
() => {
tagSizes.forEach((size) => {
tagColors.forEach((color) => {
describe(`Tag size=${size} color=${color}`, () => {
it('should call onRemove callback when delete-button is clicked', () => {
const callback = jest.fn();
const stopPropagation = jest.fn();
const wrapper = shallow(
<Tag size={size} iconName="home" value={{ label: 'Home' }} />,
<Tag size={size} color={color} value={{ label: 'Test' }} onRemove={callback} />,
);

const testIconWrapper = getByTestId(wrapper, 'Home-icon');
expect(testIconWrapper.prop('aria-label')).toBe(undefined);
expect(testIconWrapper.prop('aria-hidden')).toBe(true);
},
);

(['mobile', 'desktop'] as DeviceType[]).forEach((deviceType) => {
it(`matches snapshot (${deviceType})`, () => {
const tree = renderWithProviders(<Tag size={size} value={{ label: 'Test' }} />, 'desktop');

expect(tree).toMatchSnapshot();
});

it(`matches snapshot (${deviceType})`, () => {
const tree = renderWithProviders(<Tag size={size} value={{ label: 'Test' }} />, 'mobile');

expect(tree).toMatchSnapshot();
});

it(`matches snapshot (${deviceType} with icons)`, () => {
const tree = renderWithProviders(<Tag size={size} iconName="home" value={{ label: 'Test' }} />);
getByTestId(wrapper, 'Test-remove-button').simulate('click', { stopPropagation });

expect(tree).toMatchSnapshot();
expect(callback).toHaveBeenCalledTimes(1);
});

it(`matches snapshot (${deviceType} deletable)`, () => {
const tree = renderWithProviders(
<Tag
size={size}
value={{ label: 'Test' }}
onDelete={jest.fn()}
/>,
);

expect(tree).toMatchSnapshot();
});
it(
'should have aria-hidden="false" and an icon aria-label when label is not the same as iconName',
() => {
const wrapper = shallow(
<Tag size={size} color={color} iconName="home" value={{ label: 'Test' }} />,
);

const testIconWrapper = getByTestId(wrapper, 'Test-icon');
expect(testIconWrapper.prop('aria-label')).toBe('home');
expect(testIconWrapper.prop('aria-hidden')).toBe(false);
},
);

it(`matches snapshot (${deviceType} clickable)`, () => {
const tree = renderWithProviders(
<Tag
size={size}
value={{ label: 'Test' }}
onClick={jest.fn()}
/>,
);
it(
'should have aria-hidden="true" and no label on icon when the label is the same as the iconName',
() => {
const wrapper = shallow(
<Tag size={size} color={color} iconName="home" value={{ label: 'Home' }} />,
);

const testIconWrapper = getByTestId(wrapper, 'Home-icon');
expect(testIconWrapper.prop('aria-label')).toBe(undefined);
expect(testIconWrapper.prop('aria-hidden')).toBe(true);
},
);

expect(tree).toMatchSnapshot();
(['mobile', 'desktop'] as DeviceType[]).forEach((deviceType) => {
it(`matches snapshot (${deviceType})`, () => {
const tree = renderWithProviders(
<Tag
size={size}
color={color}
value={{ label: 'Test' }}
/>,
deviceType,
);

expect(tree).toMatchSnapshot();
});

it(`matches snapshot (${deviceType} with icons)`, () => {
const tree = renderWithProviders(
<Tag
size={size}
color={color}
iconName="home"
value={{ label: 'Test' }}
/>,
deviceType,
);

expect(tree).toMatchSnapshot();
});

it(`matches snapshot (${deviceType} removable)`, () => {
const tree = renderWithProviders(
<Tag
size={size}
color={color}
value={{ label: 'Test' }}
onRemove={jest.fn()}
/>,
deviceType,
);

expect(tree).toMatchSnapshot();
});
});
});
});
Expand Down
Loading
Loading