I'm new to RTL and am having a bit of trouble trying to write two tests for my component MyLabels
that takes in an object with a few properties. For the first test I'm getting an error TypeError: Cannot destructure property 'number' of 'undefined' or 'null'.
and I'm not sure how to write the second one. Below is what I have so far in my test file:
import React from 'react';
import { render, cleanup } from 'react-testing-library';
import MyLabels from '../MyLabels';
afterEach(cleanup);
const renderComponent = props => { render(<MyLabels {...props} />); };
describe('My Labels: ', () => {
it('renders when label data is provided', () => {
const data = {
label: { number: 3, attributes: { name: 'Jamie', state: 'Alabama' } },
};
expect(renderComponent(data)).toBeInTheDocument();
});
it('does not render if number is not in the required range'),
() => {
const data = {
task: { number: 100, attributes: { name: 'Jamie', state: 'Alabama' } },
};
const isRequiredRange = number => {num > 0 && num < 50 ? true : false}
// not sure how to write this one
};
});
Aucun commentaire:
Enregistrer un commentaire