generated from ooloo-io/reddit-timer-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* header task: first commit * header task: fixed missing default 'javascript' * header task: fixed default link: '/search/javascript' * header after first review * header fixing test * implemented unit test * header: before rebase after app-skeleton-review * resolved conflicts. Fixed unit tests * footer: initial commit * implemented Footer.js and Footer.style.js * footer: completed unit tests * hero-section: initial commit with with fixes from previous PR * hero-section: completed unit tests * hero-section: fixed linting issues in unit tests * hero-section: fixed Apps to have all unit tests pass * hero-section: added missing test descriptions in footer.js * hero-section: refactor components and file structure after review * info-section: initial commit * info-section: implemented About and How it works sections * info-section: fix link to https://ooloo.io/employers * info-section: implemented react-router-hash-link * info-section: fixed ooloo.io link * info-section: implemented unit tests * info-section: fixed linting errors * info-section: fixed linting errors * info-section: fix unit test using this: testing-library/dom-testing-library#477 (comment) * info-section: commit after review * subreddit-form: initial commit. Setup folder structure * subreddit-form: implement tests * subreddit-form: fix lint error in Header.js * subreddit-form: completed unit and e2e tests * subreddit-form: fixes and cleanup after review * load-the-data: initial commit: added LoadTheData.js * load-the-data: fetching data implemented. But unit test and e2e test filing * load-the-data: troubleshooting tests * load-the-data: continue troubleshooting tests * load-the-data: fix linting error * load-the-data: fix the code to fetch top 500 posts * load-the-data: troubleshooting unit test - 'invalid json response body at reason: Unexpected end of JSON input' * load-the-data: integration test passing * load-the-data: refactor code after review. still 1 test to fix in SearchPage.js * laod-the-data: all tests pass * heatmap: first commit: setup heatmap table * heatmap: implemented heatmap architecture * heatmap: implemented user timezone * heatmap: implemented hover, highlit and timezone * heatmap: completed implementation - start testing * heatmap: refactor component structure - set test skeleton * heatmap: complete integration tests * heatmap: complete. fix user timezone in tests * heatmap: refactor code after review * heatmap: fix all test errors. ready to merge pr * heatmap: fix last test errors. ready to merge pr
- Loading branch information
Showing
30 changed files
with
1,443 additions
and
1,934 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import React from 'react'; | ||
import { MemoryRouter, Route } from 'react-router-dom'; | ||
import { | ||
render, screen, waitForElementToBeRemoved, within, | ||
} from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import 'jest-styled-components'; | ||
|
||
import { | ||
cellBackgroundColorMap, mapWeekday, postsTimeSlots, getUserTimeZone, | ||
} from '../config'; | ||
|
||
import App from '../app'; | ||
|
||
const weekdays = Object.values(mapWeekday); | ||
const cellBackgroundColor = Object.values(cellBackgroundColorMap); | ||
|
||
const setup = (initialPath = '/') => { | ||
let history; | ||
|
||
render( | ||
<MemoryRouter initialEntries={[initialPath]}> | ||
<App /> | ||
<Route | ||
path="*" | ||
render={(props) => { | ||
history = props.history; | ||
return null; | ||
}} | ||
/> | ||
</MemoryRouter>, | ||
); | ||
return { history }; | ||
}; | ||
|
||
describe('heatmap', () => { | ||
it.each(weekdays)( | ||
'weekdays are shown from Sunday to Saturday', async (weekday) => { | ||
setup('/search/less-than-500-posts'); | ||
// find weekday container element tr.weekday | ||
// assert that it contains Sunday, Monday, Tuesday, Wednesday | ||
// Thursday, Friday, Saturday | ||
const spinner = screen.getByText('loading-spinner.svg'); | ||
|
||
await waitForElementToBeRemoved(spinner); | ||
|
||
screen.getByRole('table'); | ||
// weekday | ||
screen.getByRole('cell', { name: weekday }); | ||
}, | ||
); | ||
|
||
it.each(postsTimeSlots)( | ||
'hours are shown from 12:00am to 10:00pm', async (postsTimeSlot) => { | ||
setup('/search/reactjs'); | ||
// find hours container element th.timeline | ||
// assert that it contains 12:00am, 2:00am.. | ||
const spinner = screen.getByText('loading-spinner.svg'); | ||
|
||
await waitForElementToBeRemoved(spinner); | ||
|
||
screen.getByRole('table'); | ||
|
||
const timeSlots = screen.getAllByRole('columnheader'); | ||
// screen.debug(timeSlot); | ||
within(timeSlots[1]).getByText(postsTimeSlot); | ||
}, | ||
); | ||
|
||
it('each combination of weekday and hour is represented by a square box', async () => { | ||
setup('/search/less-than-500-posts'); | ||
|
||
const spinner = screen.getByText('loading-spinner.svg'); | ||
await waitForElementToBeRemoved(spinner); | ||
screen.getByRole('table'); | ||
|
||
const cells = await document.querySelector('td.cell'); | ||
// select cells td.cell | ||
const el = within(cells).getByText(cells.textContent); | ||
const numPosts = Number(el.textContent); | ||
|
||
expect(el).toHaveStyle({ border: 'unset', backgroundColor: '#a0ce93' }); | ||
// assert that background-color correspond to numeric innerText value | ||
expect(el).toHaveStyle({ backgroundColor: `${cellBackgroundColor[numPosts]}` }); | ||
|
||
// assert that each has width === height | ||
expect(el).toHaveStyleRule('width', '40px'); | ||
expect(el).toHaveStyleRule('height', '40px'); | ||
|
||
// assert that innerText.value is a number | ||
// expect(el).toHaveValue(numPosts); | ||
|
||
// assert that element is highlighted when hovered | ||
userEvent.hover(el); | ||
expect(el).toHaveStyle({ border: '1px solid red' }); | ||
userEvent.unhover(el); | ||
expect(el).toHaveStyle({ border: 'unset' }); | ||
|
||
// assert that element is highlighted when clicked | ||
userEvent.click(el); | ||
expect(el).toHaveStyle({ border: '1px solid red' }); | ||
}); | ||
|
||
it("the user' timezone is shown below the heatmap", async () => { | ||
setup('/search/less-than-500-posts'); | ||
// select div.timezone | ||
// assert that the element contains "America/Chicago - Central Saving Time" | ||
const spinner = screen.getByText('loading-spinner.svg'); | ||
|
||
await waitForElementToBeRemoved(spinner); | ||
screen.getByRole('table'); | ||
screen.getByText(getUserTimeZone()); | ||
}); | ||
}); |
Oops, something went wrong.