File locations:
/bite-frontend/src/app.test.js
/bite-frontend/src/Components/Navbar/Navbar.test.js
Testing modules:
- React-scripts test
- Jest
Instructions to run:
- In terminal, navigate to
/bite-frontend/
- If you haven't already, run
npm install
- Start the frontend with
npm start
- Run the tests with
npm test
App()
- Render App(Main app) using the render function from React DOM
- If there's any errors, it fails test
- Otherwise, pass test
Logo Button
- The function finds the closest
<a>
tag that has text "Bite" - Compare the href link with the expected one ("/")
- If it matches, pass test
Dashboard
- It finds all the tags with text element, "Dashboard"
- Compare the href link with the expected one ("/dashboard")
- If it matches, pass test
File location: /bite-backend/src/index.test.js
Testing module: Vanilla Javascript (no special framework or library used)
Instructions to run:
- In terminal, navigate to
/bite-backend/
- If you haven't already, run
npm install
- Start the backend with
npm start
ornode ./src/index.js
- Run the tests with
npm run tests
ornode ./src/index.test.js
test_distance()
Equivalence class: /src/index.js > app.get('/restaurants/<distance>')
- Searches for restaurants within 2 miles of San Francisco
- Loops thru results and checks that all restaurants are at most 2 miles away
- If any restaurant's distance is greater than 2, fail test
- Otherwise, pass test
test_price()
Equivalence class: /src/index.js > app.get('/restaurants?price={}')
- Searches for restaurants with price points of 1 and 4
- Loops thru results and checks that all restaurants have either one or four dollar signs
- If any restaurant has two or three dollar signs, fail test
- Otherwise, pass test
test_rating()
Equivalence class: /src/index.js > app.get('/restaurants?rating={}')
- Searches for restaurants with a rating of 4 stars (4.5 stars also permitted)
- Loops thru results and checks that all restaurants have a rating of 4 or 4.5 stars
- If any restaurant has between 1 and 3.5 stars, or 5 stars, fail test
- Otherwise, pass test
test_likes()
Equivalence class: /src/index.js > app.get('/restaurants?top_cuisines={}')
- Mocks a search from the point of view of a user who has liked 3 chinese restaurants
- Loops thru results and checks that all chinese restaurants have a relevance score of 3
- If a chinese restaurant is missing the relevance score, or it is not 3, fail test
- Otherwise, pass test
test_dislikes()
Equivalence class: /src/index.js > app.get('/restaurants?dislikes={}')
- Mocks a search from the point of view of a user who has disliked several restaurants
- Specifically those with IDs:
['HHtpR0RslupSQ99GIIwW5A', 'oa6ZaLdQNzZHP7--gxBh2g', 'J7_-faNq_Ag9qTOlDn81Pw']
- Specifically those with IDs:
- Loops thru results and checks that none of the dislikes appear
- If a restaurant's ID matches one in the list of dislikes, fail test
- Otherwise, pass test
test_sorting()
Equivalence class: /src/index.js > app.get('/restaurants?top_cuisines={}')
- Searches for restaurants in San Francisco
- Loops thru results and stores indexes of chinese restaurants
- Mocks another search for restaurants in San Francisco, but from the point of view of a user who has liked 3 chinese restaurants
- Loops thru results and compares indexes of chinese restaurants with those previously stored
- If new result's chinese restaurant's indexes are NOT exactly 3 less than previously stored indexes, fail test
- i.e. chinese restaurants should appear 3 spots higher, hence having their index subtracted by 3
- Otherwise, pass test
test_details()
Equivalence class: /src/index.js > app.get('/details/<ID>')
- Sends request to /details/ endpoint for restaurant with ID HHtpR0RslupSQ99GIIwW5A
- Checks that the name is correct, and that lists of images and business hours are returned
- If name is not 'Marufuku Ramen', fail test
- If list of images is missing, fail test
- If list of business hours is missing, fail test
- Otherwise, pass test