Merge pull request #6869 from vinzscam/copy-text-button-clipboard-api

copy-text-button: remove hidden textarea
This commit is contained in:
Johan Haals
2021-08-20 13:52:33 +02:00
committed by GitHub
7 changed files with 66 additions and 47 deletions
@@ -111,7 +111,7 @@ paths:
},
};
const { getByText } = await renderInTestApp(
const { getByText, getAllByText } = await renderInTestApp(
<Wrapper>
<EntityProvider entity={apiEntity}>
<ApiDefinitionCard />
@@ -121,6 +121,10 @@ paths:
expect(getByText(/my-name/i)).toBeInTheDocument();
expect(getByText(/custom-type/i)).toBeInTheDocument();
expect(getByText(/Custom Definition/i)).toBeInTheDocument();
expect(
getAllByText(
(_text, element) => element?.textContent === 'Custom Definition',
).length,
).toBeGreaterThan(0);
});
});
@@ -20,9 +20,13 @@ import { PlainApiDefinitionWidget } from './PlainApiDefinitionWidget';
describe('<PlainApiDefinitionWidget />', () => {
it('renders plain text', async () => {
const { getByText } = await renderInTestApp(
const { getAllByText } = await renderInTestApp(
<PlainApiDefinitionWidget definition="Hello World" language="yaml" />,
);
expect(getByText(/Hello World/i)).toBeInTheDocument();
expect(
getAllByText((_text, element) => element?.textContent === 'Hello World')
.length,
).toBeGreaterThan(0);
});
});