mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import { render } from '@testing-library/react';
|
|
import '@testing-library/jest-dom';
|
|
import AnswerIcon from 'src/components/GiftTemplate/templates/AnswerIconTemplate';
|
|
import DOMPurify from 'dompurify';
|
|
|
|
describe('AnswerIcon', () => {
|
|
test('renders correct icon when correct is true', () => {
|
|
const { container } = render(<div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(AnswerIcon({ correct: true })) }} />);
|
|
const svgElement = container.querySelector('svg');
|
|
|
|
expect(svgElement).toBeInTheDocument();
|
|
expect(svgElement).toHaveStyle(`
|
|
vertical-align: text-bottom;
|
|
display: inline-block;
|
|
margin-left: 0.1rem;
|
|
margin-right: 0.2rem;
|
|
width: 1em;
|
|
color: rgb(92, 92, 92);
|
|
`);
|
|
});
|
|
|
|
test('renders incorrect icon when correct is false', () => {
|
|
const { container } = render(<div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(AnswerIcon({ correct: false })) }} />);
|
|
const svgElement = container.querySelector('svg');
|
|
|
|
expect(svgElement).toBeInTheDocument();
|
|
expect(svgElement).toHaveStyle(`
|
|
vertical-align: text-bottom;
|
|
display: inline-block;
|
|
margin-left: 0.1rem;
|
|
margin-right: 0.2rem;
|
|
width: 0.75em;
|
|
color: rgb(79, 216, 79);
|
|
`);
|
|
});
|
|
});
|