This repository was archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Merged
Tests #12
Changes from 33 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
a4ce3ca
Create basic redux actions unit tests
developer239 054c627
Update jest collect coverage settings
developer239 ecb3da2
Write basic reducer integration test
developer239 283478e
Remove redux actions unit tests
developer239 d695e9f
Add react-testing-library and jest-styled-components dependencies
developer239 96a137b
Create basic button component unit test
developer239 6215985
Create basic button component snapshot
developer239 592604b
Create test case for disabled button
developer239 67fe678
Create failing test for not found page
developer239 95b8e31
Create successful test for not found page
developer239 c61a349
Create basic products list snapshot test
developer239 1cc2c59
Create basic products list snapshot test when products loaded
developer239 02bed15
Fix react-testing-library react-hooks errors
developer239 016098f
Add jest-mock dependency
developer239 08e4cea
Added CartItem product id into array
arnostpleskot c4bd7cd
Getting rid of classes
arnostpleskot 5e1aaa8
Adding number of products per size selector
arnostpleskot 21635ee
Refactored getting url params in product list
arnostpleskot 5fdc5dd
Mock Fetch requests
developer239 b3f09d2
ramdify
varholak-peter dcf549c
Create basic tests for product detail page
developer239 91a2813
Create basic tests for cart page
developer239 6831962
Use routes constants instead of hard-coded routes
developer239 e601196
Create basic test for not-logged-in user on account page
developer239 3642e2e
Create basic test user account page
developer239 6c5c135
Create basic signup page test
developer239 21ed32b
Write advanced tests for signup page
developer239 7b0e673
Replace hard-coded user data with constant mock user data
developer239 8104b90
Write tests for sign in page
developer239 5687627
Merge branch 'week5-homework' of https://github.com/strvcom/react-nig…
developer239 026e2fe
Update products list snapshot
developer239 365a1d1
Fix typo
developer239 3fe0468
Polish source code
developer239 741a015
Make store mock nicer
developer239 ac821ce
Detect account page by page-id
developer239 8fcb048
Fix snapshot tests
developer239 584b989
Install cypress
developer239 529852b
Initialize cypress
developer239 03f45e1
Add eslint-plugin-cypress
developer239 e58c97c
Fix cypress base url
developer239 4dc68aa
Write basic cypress test
developer239 1fb47c2
Fix cypress test
developer239 ba0a6ed
Resolve tasks from code review
developer239 fa13c9e
Merge branch 'master' of https://github.com/strvcom/react-nights-2018…
developer239 c6635c0
Run tests before every commit
developer239 0ceeb98
Add cross-env
developer239 02e2c23
Revert "Add cross-env"
developer239 daffaa2
Revert "Run tests before every commit"
developer239 15e7a9a
Recover README files 💣
developer239 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
53 changes: 53 additions & 0 deletions
53
src/components/Button/test/__snapshots__/index.test.js.snap
This file contains hidden or 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,53 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`[components] Button should render correctly 1`] = ` | ||
| .c0 { | ||
| background: #ef0d33; | ||
| cursor: pointer; | ||
| padding: 1rem; | ||
| margin-top: 0.5rem; | ||
| border: none; | ||
| border-radius: 5px; | ||
| color: #fff; | ||
| } | ||
|
|
||
| <body> | ||
| <div> | ||
| <button | ||
| class="c0" | ||
| > | ||
| My Button | ||
| </button> | ||
| </div> | ||
| </body> | ||
| `; | ||
|
|
||
| exports[`[components] Button when disabled should render correctly 1`] = ` | ||
| <body> | ||
| <div> | ||
| <button | ||
| class="Button-sc-2y5gim-0 iFNPkt" | ||
| > | ||
| My Button | ||
| </button> | ||
| </div> | ||
| .c0 { | ||
| background: #e5e5e5; | ||
| cursor: default; | ||
| padding: 1rem; | ||
| margin-top: 0.5rem; | ||
| border: none; | ||
| border-radius: 5px; | ||
| color: #fff; | ||
| } | ||
|
|
||
| <div> | ||
| <button | ||
| class="c0" | ||
| disabled="" | ||
| > | ||
| My Button | ||
| </button> | ||
| </div> | ||
| </body> | ||
| `; |
This file contains hidden or 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,20 @@ | ||
| import React from 'react' | ||
| import { render } from 'react-testing-library' | ||
| import 'jest-styled-components' | ||
|
|
||
| import Button from '../index' | ||
|
|
||
| // This is just an example how to test components | ||
| describe('[components] Button', () => { | ||
| it('should render correctly', () => { | ||
| const renderer = render(<Button>My Button</Button>) | ||
| expect(renderer.baseElement).toMatchSnapshot() | ||
| }) | ||
|
|
||
| describe('when disabled', () => { | ||
| it('should render correctly', () => { | ||
| const renderer = render(<Button disabled>My Button</Button>) | ||
| expect(renderer.baseElement).toMatchSnapshot() | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or 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 hidden or 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 hidden or 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,16 @@ | ||
| import React from 'react' | ||
|
|
||
| const options = [10, 25, 50, 100] | ||
|
|
||
| const SizeSelect = ({ onChange, value }) => ( | ||
| // eslint-disable-next-line jsx-a11y/no-onchange | ||
| <select onChange={onChange} value={value}> | ||
| {options.map(number => ( | ||
| <option value={number} key={number}> | ||
| {number} | ||
| </option> | ||
| ))} | ||
| </select> | ||
| ) | ||
|
|
||
| export { SizeSelect } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,39 @@ | ||
| import React from 'react' | ||
| import 'jest-styled-components' | ||
|
|
||
| import { App } from '../../../App' | ||
| import * as routes from '../../../routes' | ||
| import { renderWithRouter } from '../../../utilsTest/render' | ||
| import { configureStore } from '../../../store' | ||
| import { USER } from '../../../utilsTest/mockData' | ||
|
|
||
| describe('[pages] Account', () => { | ||
| describe('when not logged in', () => { | ||
| it('should redirect to login page', () => { | ||
| const renderer = renderWithRouter(<App />, routes.ACCOUNT) | ||
| const HTMLDivElement = renderer.getByTestId('login-page') | ||
| expect(HTMLDivElement).toBeTruthy() | ||
| }) | ||
| }) | ||
|
|
||
| describe('when logged in', () => { | ||
| it('should render private user account page', async () => { | ||
| const store = configureStore({ | ||
| customer: { | ||
| attributes: { | ||
| metadata: { | ||
| firstName: USER.firstName, | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| const renderer = renderWithRouter( | ||
| <App customStore={store} />, | ||
| routes.ACCOUNT | ||
| ) | ||
| const H1HtmlElement = renderer.getByText(`Welcome ${USER.firstName}`) | ||
|
developer239 marked this conversation as resolved.
Outdated
|
||
| expect(H1HtmlElement).toBeTruthy() | ||
| }) | ||
| }) | ||
| }) | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.