-
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #625 from gregberge/icon-size
feat: allow to specify icon size
- Loading branch information
Showing
12 changed files
with
265 additions
and
74 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,41 @@ | ||
import { transform } from '@babel/core' | ||
import plugin from '.' | ||
import plugin, { Options } from '.' | ||
|
||
const testPlugin = (code: string) => { | ||
const testPlugin = (code: string, options?: Options) => { | ||
const result = transform(code, { | ||
plugins: ['@babel/plugin-syntax-jsx', plugin], | ||
plugins: ['@babel/plugin-syntax-jsx', [plugin, options]], | ||
configFile: false, | ||
}) | ||
|
||
return result?.code | ||
} | ||
|
||
describe('plugin', () => { | ||
it('should replace width / height attributes', () => { | ||
it('replaces width / height attributes', () => { | ||
expect( | ||
testPlugin('<svg foo="bar" width="100" height="200" />'), | ||
).toMatchInlineSnapshot( | ||
`"<svg foo=\\"bar\\" width=\\"1em\\" height=\\"1em\\" />;"`, | ||
) | ||
}) | ||
|
||
it('should add theme if they are not present', () => { | ||
it('adds theme if they are not present', () => { | ||
expect(testPlugin('<svg foo="bar" />')).toMatchInlineSnapshot( | ||
`"<svg foo=\\"bar\\" width=\\"1em\\" height=\\"1em\\" />;"`, | ||
) | ||
}) | ||
|
||
it('accepts numeric values', () => { | ||
expect( | ||
testPlugin('<svg foo="bar" />', { width: 24, height: 24 }), | ||
).toMatchInlineSnapshot(`"<svg foo=\\"bar\\" width={24} height={24} />;"`) | ||
}) | ||
|
||
it('accepts string values', () => { | ||
expect( | ||
testPlugin('<svg foo="bar" />', { width: '2em', height: '2em' }), | ||
).toMatchInlineSnapshot( | ||
`"<svg foo=\\"bar\\" width=\\"2em\\" height=\\"2em\\" />;"`, | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1c5f163
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: