Skip to content

Commit

Permalink
Remove custom svg transformer for tests
Browse files Browse the repository at this point in the history
Use the default one provided by sewing-kit. We're about to change how
icons get loaded so there's no point having a transformer that mimics
the old way.

The only reason why we needed it was for some Spinner tests, which can
be expressed in a different way
  • Loading branch information
BPScott committed Feb 20, 2019
1 parent e4b9514 commit bb9cbba
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
18 changes: 0 additions & 18 deletions config/jest/transformers/svg.js

This file was deleted.

8 changes: 0 additions & 8 deletions sewing-kit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ export default function sewingKitConfig(

config.setupFiles.push(join(tests, 'setup.ts'));

// svg transform have to go before the existing transforms so that .svg
// files match our declaration first, and thus run the svg transform,
// instead of matching the file transform
config.transform = {
'\\.svg$': join(__dirname, 'config/jest/transformers/svg.js'),
...config.transform,
};

// Code coverage
config.collectCoverageFrom = [
'src/**/*.{ts,tsx}',
Expand Down
8 changes: 4 additions & 4 deletions src/components/Spinner/tests/Spinner.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ describe('<Spinner />', () => {
describe('size', () => {
it('renders a large spinner by default', () => {
const spinner = shallowWithAppProvider(<Spinner />);
expect(spinner.find('svg').prop('viewBox')).toBe('0 0 44 44');
expect(spinner.find('svg').hasClass('sizeLarge')).toBeTruthy();
});

it('renders a large spinner when size is large', () => {
const spinner = shallowWithAppProvider(<Spinner size="large" />);
expect(spinner.find('svg').prop('viewBox')).toBe('0 0 44 44');
expect(spinner.find('svg').hasClass('sizeLarge')).toBeTruthy();
});

it('renders a small spinner when size is small', () => {
const spinner = shallowWithAppProvider(<Spinner size="small" />);
expect(spinner.find('svg').prop('viewBox')).toBe('0 0 20 20');
expect(spinner.find('svg').hasClass('sizeSmall')).toBeTruthy();
});

it('renders a small spinner when color is white even if size is large', () => {
const spinner = shallowWithAppProvider(
<Spinner size="large" color="white" />,
);
expect(spinner.find('svg').prop('viewBox')).toBe('0 0 20 20');
expect(spinner.find('svg').hasClass('sizeSmall')).toBeTruthy();
});
});

Expand Down

0 comments on commit bb9cbba

Please sign in to comment.