mirror of https://github.com/grafana/grafana
Explore: Fix incorrect interpolation of table title (#80227)
parent
127decee1e
commit
313c43749c
@ -0,0 +1,26 @@ |
|||||||
|
import { render } from '@testing-library/react'; |
||||||
|
import React from 'react'; |
||||||
|
|
||||||
|
import { Trans } from './index'; |
||||||
|
|
||||||
|
describe('internationalization', () => { |
||||||
|
describe('Trans component', () => { |
||||||
|
it('should interpolate strings without escaping dangerous characters', () => { |
||||||
|
const name = '<script></script>'; |
||||||
|
const { getByText } = render(<Trans i18nKey="explore.table.title-with-name">Table - {{ name }}</Trans>); |
||||||
|
|
||||||
|
expect(getByText('Table - <script></script>')).toBeInTheDocument(); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should escape dangerous characters when shouldUnescape is false', () => { |
||||||
|
const name = '<script></script>'; |
||||||
|
const { getByText } = render( |
||||||
|
<Trans i18nKey="explore.table.title-with-name" shouldUnescape={false}> |
||||||
|
Table - {{ name }} |
||||||
|
</Trans> |
||||||
|
); |
||||||
|
|
||||||
|
expect(getByText('Table - <script></script>')).toBeInTheDocument(); |
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
Loading…
Reference in new issue