Skip to content

Commit

Permalink
chore(Skeleton): update SkeletonPlaceholder, SkeletonText, SkeletonIc…
Browse files Browse the repository at this point in the history
…on & IconSkeleton tests to RTL (#11632)

* chore: update Skeleton icon test

* chore: add IconSkeleton test

* chore: update SkeletonPlaceholder tests

* chore: update SkeletonText tests
  • Loading branch information
jnm2377 authored Jun 22, 2022
1 parent 30f7ebd commit 413adc4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
17 changes: 17 additions & 0 deletions packages/react/src/components/Icon/Icon.Skeleton-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import { render, screen } from '@testing-library/react';
import React from 'react';
import IconSkeleton from './Icon.Skeleton';

describe('IconSkeleton', () => {
it('should pass in an extra className when one is given', () => {
render(<IconSkeleton className="custom-class" data-testid="skeleton" />);
expect(screen.getByTestId('skeleton')).toHaveClass('custom-class');
});
});
11 changes: 4 additions & 7 deletions packages/react/src/components/SkeletonIcon/SkeletonIcon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@

import React from 'react';
import SkeletonIcon from '../SkeletonIcon';
import { shallow } from 'enzyme';

const prefix = 'cds';
import { render, screen } from '@testing-library/react';

describe('SkeletonIcon', () => {
const wrapper = shallow(<SkeletonIcon />);

it('Has the expected classes', () => {
expect(wrapper.hasClass(`${prefix}--icon--skeleton`)).toEqual(true);
it('should pass in an extra className when one is given', () => {
render(<SkeletonIcon className="custom-class" data-testid="skeleton" />);
expect(screen.getByTestId('skeleton')).toHaveClass('custom-class');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@

import React from 'react';
import SkeletonPlaceholder from '../SkeletonPlaceholder';
import { shallow } from 'enzyme';

const prefix = 'cds';
import { render, screen } from '@testing-library/react';

describe('SkeletonPlaceholder', () => {
const wrapper = shallow(<SkeletonPlaceholder />);

it('Has the expected classes', () => {
expect(wrapper.hasClass(`${prefix}--skeleton__placeholder`)).toEqual(true);
it('should pass in an extra className when one is given', () => {
render(
<SkeletonPlaceholder className="custom-class" data-testid="skeleton" />
);
expect(screen.getByTestId('skeleton')).toHaveClass('custom-class');
});
});
22 changes: 9 additions & 13 deletions packages/react/src/components/SkeletonText/SkeletonText-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,22 @@

import React from 'react';
import SkeletonText from '../SkeletonText';
import { shallow } from 'enzyme';
import { render, screen } from '@testing-library/react';

const prefix = 'cds';

describe('SkeletonText', () => {
describe('Renders as expected', () => {
const wrapper = shallow(<SkeletonText />);

it('Has the expected classes', () => {
expect(wrapper.hasClass(`${prefix}--skeleton__text`)).toEqual(true);
});
it('should pass in an extra className when one is given', () => {
render(<SkeletonText className="custom-class" data-testid="skeleton" />);
expect(screen.getByTestId('skeleton')).toHaveClass('custom-class');
});
});

describe('SkeletonText Heading', () => {
describe('Renders as expected', () => {
const wrapper = shallow(<SkeletonText heading />);

it('Has the expected classes', () => {
expect(wrapper.hasClass(`${prefix}--skeleton__heading`)).toEqual(true);
});
it('should add heading classNames when the heading prop is passed in', () => {
render(<SkeletonText heading data-testid="skeleton2" />);
expect(screen.getByTestId('skeleton2')).toHaveClass(
`${prefix}--skeleton__heading`
);
});
});

0 comments on commit 413adc4

Please sign in to comment.