Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colebemis committed Aug 20, 2023
1 parent 5af811a commit 3b2d2cb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ jobs:

- name: Optimize SVGs
run: |
npm run optimize
npm run optimize-svgs
if git diff --quiet; then
echo "All SVGs are optimized ✔︎"
else
echo "The following SVGs are not optimized:"
echo
git diff --name-only
echo
echo "Please run `npm run optimize` and commit the changes"
echo "Please run `npm run optimize-svgs` and commit the changes"
exit 1
fi
10 changes: 10 additions & 0 deletions bin/__tests__/__snapshots__/optimize-svg.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`optimizes SVG correctly 1`] = `"<svg xmlns=\\"http://www.w3.org/2000/svg\\" width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" fill=\\"none\\" stroke=\\"currentColor\\" stroke-width=\\"2\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\"><line x1=\\"23\\" y1=\\"1\\" x2=\\"1\\" y2=\\"23\\"/><line x1=\\"1\\" y1=\\"1\\" x2=\\"23\\" y2=\\"23\\"/></svg>"`;
exports[`rejects when passed unparsable SVG string 1`] = `
[Error: Error in parsing SVG: Unclosed root tag
Line: 0
Column: 10
Char: ]
`;
26 changes: 0 additions & 26 deletions bin/__tests__/__snapshots__/process-svg.test.js.snap

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-env jest */
import processSvg from '../process-svg';
import optimizeSvg from '../optimize-svg';

test('processes SVG correctly', () => {
test('optimizes SVG correctly', () => {
const SVG =
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><title>Title</title><line x1="23" y1="1" x2="1" y2="23" fill="none" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/><line x1="1" y1="1" x2="23" y2="23" fill="none" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/></svg>';

expect(processSvg(SVG)).resolves.toMatchSnapshot();
expect(optimizeSvg(SVG)).resolves.toMatchSnapshot();
});

test('rejects when passed unparsable SVG string', () => {
const UNPARSABLE_SVG = '<svg></svg';

expect(processSvg(UNPARSABLE_SVG)).rejects.toMatchSnapshot();
expect(optimizeSvg(UNPARSABLE_SVG)).rejects.toMatchSnapshot();
});

0 comments on commit 3b2d2cb

Please sign in to comment.