From e3aaf8d61e6abde276d4f5649bf86723515ac73c Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Wed, 14 Mar 2018 21:25:32 -0400 Subject: more tests, remove unnessecary files --- frontend/__tests__/CartItem.test.js | 33 ++++++++++++++++++++++ .../__tests__/__snapshots__/CartItem.test.js.snap | 33 ++++++++++++++++++++++ .../__tests__/__snapshots__/CartList.test.js.snap | 33 ++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 frontend/__tests__/CartItem.test.js create mode 100644 frontend/__tests__/__snapshots__/CartItem.test.js.snap create mode 100644 frontend/__tests__/__snapshots__/CartList.test.js.snap (limited to 'frontend/__tests__') diff --git a/frontend/__tests__/CartItem.test.js b/frontend/__tests__/CartItem.test.js new file mode 100644 index 0000000..42dd39b --- /dev/null +++ b/frontend/__tests__/CartItem.test.js @@ -0,0 +1,33 @@ +import React from 'react'; +import { shallow, mount } from 'enzyme'; +import toJSON from 'enzyme-to-json'; +import CartItem from '../components/CartItem'; + +const cartItem = { + item: { + price: 5000, + image: 'dog.jpg', + title: 'Fake Item', + }, + id: 'abc123', + quantity: 20, +}; + +describe('', () => { + it('renders and matches snapshot', () => { + const wrapper = shallow(); + expect(toJSON(wrapper)).toMatchSnapshot(); + }); + + it('renders a single quantity', () => { + const wrapper = shallow(); + const p = wrapper.find('p'); + expect(p.text()).toBe('$50 — 1 × $50 each'); + }); + + it('renders multiples', () => { + const wrapper = shallow(); + const p = wrapper.find('p'); + expect(p.text()).toBe('$1,171,150 — 23423 × $50 each'); + }); +}); diff --git a/frontend/__tests__/__snapshots__/CartItem.test.js.snap b/frontend/__tests__/__snapshots__/CartItem.test.js.snap new file mode 100644 index 0000000..1f3cca5 --- /dev/null +++ b/frontend/__tests__/__snapshots__/CartItem.test.js.snap @@ -0,0 +1,33 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` renders and matches snapshot 1`] = ` + + Fake Item +
+

+ Fake Item +

+

+ $1,000 + — + + 20 + × + $50 + each + +

+
+ +
+`; diff --git a/frontend/__tests__/__snapshots__/CartList.test.js.snap b/frontend/__tests__/__snapshots__/CartList.test.js.snap new file mode 100644 index 0000000..1f3cca5 --- /dev/null +++ b/frontend/__tests__/__snapshots__/CartList.test.js.snap @@ -0,0 +1,33 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` renders and matches snapshot 1`] = ` + + Fake Item +
+

+ Fake Item +

+

+ $1,000 + — + + 20 + × + $50 + each + +

+
+ +
+`; -- cgit v1.3