Skip to content

Week 2 Assignment#8

Open
kaa-no wants to merge 1 commit into
modern-web-application-uw18:masterfrom
kaa-no:master
Open

Week 2 Assignment#8
kaa-no wants to merge 1 commit into
modern-web-application-uw18:masterfrom
kaa-no:master

Conversation

@kaa-no

@kaa-no kaa-no commented May 17, 2018

Copy link
Copy Markdown

No description provided.

import React from 'react';
import ReactDOM from 'react-dom';
import RentalCart from './RentalCart';
import TestRenderer from 'react-test-renderer';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When installing third-party modules like react-test-renderer, make sure to use the --save flag so it's saved to package.json

describe("RentalCart", () => {
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<RentalCart homesCart={homesCart()} cancelYourRent={() => {}} whatRentalTotal={() => { return 0; }} />, div);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are not defined. Instead, you'll want to pass some fake data via props.

ReactDOM.unmountComponentAtNode(div);
});

it('Should render component with list of rental cart info and total', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job w/the snapshot tests

whatRentalTotal = () => {
var costTotal = 0;
for (var i = 0; i < this.state.productsInCart.length; i++) {
costTotal = costTotal + this.state.productsInCart[i].payment.cost;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants