Skip to content

Instantly share code, notes, and snippets.

@TCotton
Created November 20, 2020 20:55
Show Gist options
  • Save TCotton/86546abd3f391e7b023cad5603ff6ed0 to your computer and use it in GitHub Desktop.
Save TCotton/86546abd3f391e7b023cad5603ff6ed0 to your computer and use it in GitHub Desktop.
chapter one - react test
import React from 'react';
export const Appointment = ({customer: { firstName }}) => <div>{firstName}</div>;
import React from 'react';
import ReactDOM from 'react-dom'
import { Appointment } from '../src/Appointment';
let container;
let component;
const render = component => ReactDOM.render(component, container);
describe("Appointment", () => {
beforeEach(() => {
container = document.createElement('div');;
});
it('renders the custom first name', () => {
const customer = { firstName: 'Ashley'};
component = <Appointment customer={customer} />
render(component, container);
expect(container.textContent).toMatch('Ashley');
})
it('renders another customer first name', () => {
const customer = { firstName: 'Jordon'};
component = <Appointment customer={customer} />
render(component, container);
expect(container.textContent).toMatch('Jordon');
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment