React Jest Enzyme Question

The following test are form exercise 13 FCC front end development libraries React:

// The date prop of the CurrentDate should contain a string of text.

// The date prop should be generated by calling Date()

// The CurrentDate component should render the value from the date prop in the p tag.

I’ve managed to some of the tests working but not the above. Are you guys aware of any resources that could help me figure this out.

import React from "react"

export const CurrentDate = (props) =>{
    return(
    <div>
        <p>Current date: {props.date}</p>
    </div>
    )
}

export class Calendar extends React.Component{
    constructor(props){
        super(props);
    }

    render(){
        return(
            <div>
                <h3>What date is it?</h3>
                <CurrentDate date={Date()} />
            </div>
        )
    }
};
import {Calendar, CurrentDate} from '../components/13passPropsToAStatelessFunctionalComponent';


describe('Pass Props to a Stateless Functional Component', () => {

    let wrapperCalendar;
    let wrapperCurrentDate;

    beforeEach(() => {
        wrapperCalendar = shallow(<Calendar />);
        wrapperCurrentDate = shallow(<CurrentDate />)

   });

    it('The Calendar component should return a single div element.', () => {  
        expect(wrapperCalendar.at(0).exists('div')).toBe(true)     
    });

    it('The second child of the Calendar component should be the CurrentDate component.', ()=>{
        expect(wrapperCalendar.children(0).at(1).exists('CurrentDate')).toBe(true)
    })
});

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.