From 79eeac6e5cc42a918aca4be9e1adda3d58e0582c Mon Sep 17 00:00:00 2001 From: Branden Jones Date: Wed, 24 Apr 2024 11:35:35 -0400 Subject: [PATCH] cleanup and initial TDD (fail) --- __tests__/App.test.js | 8 ------ cypress/e2e/listing-restaurants.cy.js | 18 +++++++++++++ cypress/e2e/smoke.cy.js | 6 ----- package.json | 2 +- public/index.html | 2 +- src/App.css | 38 --------------------------- src/App.js | 29 +++----------------- src/index.css | 13 --------- src/index.js | 9 +------ src/logo.svg | 1 - src/reportWebVitals.js | 13 --------- 11 files changed, 25 insertions(+), 114 deletions(-) delete mode 100644 __tests__/App.test.js create mode 100644 cypress/e2e/listing-restaurants.cy.js delete mode 100644 cypress/e2e/smoke.cy.js delete mode 100644 src/App.css delete mode 100644 src/index.css delete mode 100644 src/logo.svg delete mode 100644 src/reportWebVitals.js diff --git a/__tests__/App.test.js b/__tests__/App.test.js deleted file mode 100644 index bcf2741..0000000 --- a/__tests__/App.test.js +++ /dev/null @@ -1,8 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import App from '../src/App'; - -test('renders learn react link', () => { - render(); - const linkElement = screen.getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/cypress/e2e/listing-restaurants.cy.js b/cypress/e2e/listing-restaurants.cy.js new file mode 100644 index 0000000..a51d23a --- /dev/null +++ b/cypress/e2e/listing-restaurants.cy.js @@ -0,0 +1,18 @@ +describe('Listing Restaurants', () => +{ + it('shows restaurants from the server', () => + { + const sushiPlace = "Sushi Place"; + const pizzaPlace = "Pizza Place"; + + cy.intercept('GET', 'https://api.outsidein.dev/*/restaurants', + [ + {id: 850, name: sushiPlace}, + {id: 851, name: pizzaPlace} + ]); + + cy.visit('/'); + cy.contains(sushiPlace); + cy.contains(pizzaPlace); + }) +}) \ No newline at end of file diff --git a/cypress/e2e/smoke.cy.js b/cypress/e2e/smoke.cy.js deleted file mode 100644 index 8af772f..0000000 --- a/cypress/e2e/smoke.cy.js +++ /dev/null @@ -1,6 +0,0 @@ -describe('Smoke Test', () => { - it('can view the home page', () => { - cy.visit('/'); - cy.contains('Learn React'); - }) -}) \ No newline at end of file diff --git a/package.json b/package.json index 04a8143..e09fbd2 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", - "cypress": "npm run cypress open" + "cypress": "cypress open" }, "eslintConfig": { "extends": [ diff --git a/public/index.html b/public/index.html index aa069f2..76f1bb8 100644 --- a/public/index.html +++ b/public/index.html @@ -24,7 +24,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - React App + Opinion Ate diff --git a/src/App.css b/src/App.css deleted file mode 100644 index 74b5e05..0000000 --- a/src/App.css +++ /dev/null @@ -1,38 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.js b/src/App.js index 3784575..bd268fd 100644 --- a/src/App.js +++ b/src/App.js @@ -1,25 +1,4 @@ -import logo from './logo.svg'; -import './App.css'; - -function App() { - return ( -
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
-
- ); -} - -export default App; +export default function App() +{ + return
Hello, World
+} \ No newline at end of file diff --git a/src/index.css b/src/index.css deleted file mode 100644 index ec2585e..0000000 --- a/src/index.css +++ /dev/null @@ -1,13 +0,0 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} diff --git a/src/index.js b/src/index.js index d563c0f..5851d84 100644 --- a/src/index.js +++ b/src/index.js @@ -1,17 +1,10 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; -import './index.css'; import App from './App'; -import reportWebVitals from './reportWebVitals'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( -); - -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -reportWebVitals(); +); \ No newline at end of file diff --git a/src/logo.svg b/src/logo.svg deleted file mode 100644 index 9dfc1c0..0000000 --- a/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/reportWebVitals.js b/src/reportWebVitals.js deleted file mode 100644 index 5253d3a..0000000 --- a/src/reportWebVitals.js +++ /dev/null @@ -1,13 +0,0 @@ -const reportWebVitals = onPerfEntry => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; - -export default reportWebVitals;