@eureca/eureca-ui
Version:
UI component library of Eureca's user and admin apps
37 lines (29 loc) • 1.24 kB
JavaScript
import React from 'react';
import { EvaluationScore } from '../evaluation-score';
import { render } from '@testing-library/react';
function renderEvaluationScore(props) {
return render(<EvaluationScore {...props} />);
}
describe('Evaluation Score component', () => {
it('show the final title', () => {
const { getByTestId } = renderEvaluationScore({ score: 10, final: true });
const title = getByTestId('title-testid');
expect(title.textContent).toBe('Pontuação final');
});
it('show a custom title', () => {
const { getByTestId } = renderEvaluationScore({ score: 5, title: 'Teste' });
const title = getByTestId('title-testid');
expect(title.textContent).toBe('Pontuação Teste');
});
it('shows the score as result', () => {
const score = Math.floor(Math.random() * 10) + 1;
const { getByTestId } = renderEvaluationScore({ score });
const { textContent } = getByTestId('result-testid');
expect(Number(textContent)).toBe(score);
});
it('parse and add a 0 before numbers with value less than 10', () => {
const { getByTestId } = renderEvaluationScore({ score: 3 });
const { textContent } = getByTestId('result-testid');
expect(textContent).toBe('03');
});
});