Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto ID's for react-intl components
Generates and inserts globally unique id props for react-intl React components FormattedMessage and FormattedHTMLMessage
- Loading branch information
1 parent
659bd61
commit 504c729
Showing
9 changed files
with
612 additions
and
15 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
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 |
---|---|---|
@@ -0,0 +1,255 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`default default: default 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"src.__fixtures__.613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; | ||
|
||
exports[`default does nothing if component props are spread: does nothing if component props are spread 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
const props = { defaultMessage: 'hello' }; | ||
console.log(<FormattedMessage {...props} />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
const props = { defaultMessage: 'hello' }; | ||
console.log(<FormattedMessage {...props} />); | ||
" | ||
`; | ||
|
||
exports[`default does nothing if components not imported from react-intl: does nothing if components not imported from react-intl 1`] = ` | ||
" | ||
import any from 'any-module' | ||
console.log(<FormattedMessage defaultMessage={getMsg()} />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import any from 'any-module'; | ||
console.log(<FormattedMessage defaultMessage={getMsg()} />); | ||
" | ||
`; | ||
|
||
exports[`default multiple uses: multiple uses 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
console.log(<FormattedMessage defaultMessage=\\"another\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"src.__fixtures__.613153351\\" defaultMessage=\\"hello\\" />); | ||
console.log(<FormattedMessage id=\\"src.__fixtures__.1418522856\\" defaultMessage=\\"another\\" />); | ||
" | ||
`; | ||
|
||
exports[`default with FormattedMessage imported as something else: with FormattedMessage imported as something else 1`] = ` | ||
" | ||
import { FormattedMessage as T } from 'react-intl' | ||
console.log(<T defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage as T } from 'react-intl'; | ||
console.log(<T id=\\"src.__fixtures__.613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; | ||
|
||
exports[`default with FormattedMessage nested in other JSX: with FormattedMessage nested in other JSX 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log( | ||
<div> | ||
<FormattedMessage defaultMessage=\\"hello\\" /> | ||
</div> | ||
); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<div> | ||
<FormattedMessage id=\\"src.__fixtures__.613153351\\" defaultMessage=\\"hello\\" /> | ||
</div>); | ||
" | ||
`; | ||
|
||
exports[`default with a value interpolated in the message: with a value interpolated in the message 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage={\`hello world 2\`} />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"src.__fixtures__.3540954520\\" defaultMessage={\`hello world 2\`} />); | ||
" | ||
`; | ||
exports[`default with a variable as the defaultMessage: with a variable as the defaultMessage 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
const message = \\"variable message\\"; | ||
console.log(<FormattedMessage defaultMessage={message} />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
const message = \\"variable message\\"; | ||
console.log(<FormattedMessage id=\\"src.__fixtures__.3082794952\\" defaultMessage={message} />); | ||
" | ||
`; | ||
exports[`extractComments = false default: default 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"src.__fixtures__.613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; | ||
exports[`filebase = true default: default 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"src.__fixtures__.messages.613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; | ||
exports[`includeExportName = all default: default 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"src.__fixtures__.613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; | ||
exports[`includeExportName = true default: default 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"src.__fixtures__.613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; | ||
exports[`removePrefix = "src" default: default 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"__fixtures__.613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; | ||
exports[`removePrefix = "src/" -- with slash default: default 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"__fixtures__.613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; | ||
exports[`removePrefix = false default: default 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"src.__fixtures__.613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; | ||
exports[`removePrefix = true, includeExportName = all default: default 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; | ||
exports[`removePrefix = true, includeExportName = true default: default 1`] = ` | ||
" | ||
import { FormattedMessage } from 'react-intl' | ||
console.log(<FormattedMessage defaultMessage=\\"hello\\" />); | ||
↓ ↓ ↓ ↓ ↓ ↓ | ||
import { FormattedMessage } from 'react-intl'; | ||
console.log(<FormattedMessage id=\\"613153351\\" defaultMessage=\\"hello\\" />); | ||
" | ||
`; |
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.