-
-
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.
BREAKING CHANGE: using --icon as latest arg now requires "--" Fix #571
- Loading branch information
Showing
11 changed files
with
237 additions
and
46 deletions.
There are no files selected for viewing
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
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
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.