Skip to content

Commit

Permalink
Merge pull request #3 from dfiedlerx/feat/remove_persist
Browse files Browse the repository at this point in the history
feat: 🎸 remove persist
  • Loading branch information
dfiedlerx authored Aug 3, 2023
2 parents c1943d4 + 9c2bb2b commit f5ed4ec
Show file tree
Hide file tree
Showing 26 changed files with 158 additions and 381 deletions.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
npm run lint:fix
npx lint-staged
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Routes
npx generate-react-cli component page-generated --type=route
Screens
npx generate-react-cli component page-generated --type=screen
Services
npx generate-react-cli component service-generated --type=service

## Learn More

Expand Down
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
extends: ['@commitlint/config-conventional'],
}
117 changes: 12 additions & 105 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"test": "jest --forceExit --coverage --no-cache --detectOpenHandles --passWithNoTests",
"test:dev": "jest --watch --forceExit --coverage --no-cache --detectOpenHandles --passWithNoTests",
"lint": "next lint",
"lint:fix": "eslint --fix --ext .js,.jsx,.tsx,.ts .",
"prepare": "husky install"
},
"dependencies": {
Expand All @@ -22,7 +23,6 @@
"react-dom": "18.2.0",
"react-icons": "^4.10.1",
"react-redux": "^8.1.2",
"redux-persist": "^6.0.0",
"tailwind-variants": "^0.1.13",
"tailwindcss": "3.3.3"
},
Expand All @@ -35,25 +35,24 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/node": "20.4.5",
"@types/node": "20.4.6",
"@types/react": "18.2.18",
"@types/react-dom": "18.2.7",
"@types/whatwg-fetch": "^0.0.33",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"babel-loader": "^9.1.3",
"commitlint": "^17.6.7",
"eslint": "^8.46.0",
"eslint-config-next": "13.4.12",
"eslint-config-prettier": "^8.9.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^8.0.3",
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"jest-fetch-mock": "^3.0.3",
"lint-staged": "^13.2.3",
"prettier": "^3.0.0",
"prettier": "^3.0.1",
"typescript": "5.1.6",
"web-vitals": "^3.4.0",
"webpack": "^5.88.2"
Expand Down
19 changes: 19 additions & 0 deletions src/app/(redux)/redux-example/page.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import userEvent from '@testing-library/user-event'

import Page from '@/app/(redux)/redux-example/page'
import useRouterMock, { pushMock } from '@/mocks/useRouter.mock'
import { resetStore } from '@/redux/store/store'
import { render, screen, waitFor } from '@/utils/test-utils'

jest.mock('next/navigation', () => ({
useRouter() {
return useRouterMock
},
}))

describe('@/app/(redux)/redux-example/page', () => {
beforeEach(() => {
resetStore()
Expand Down Expand Up @@ -55,4 +62,16 @@ describe('@/app/(redux)/redux-example/page', () => {
expect(screen.getByText('0')).toBeInTheDocument()
})
})

it('should redirect when clicked', async () => {
render(<Page />)
expect(screen.getByText(0)).toBeInTheDocument()

const decrement = screen.getByText('redirect')
await userEvent.click(decrement)

await waitFor(() => {
expect(pushMock).toHaveBeenCalledWith('/redux-persist-example')
})
})
})
14 changes: 13 additions & 1 deletion src/app/(redux)/redux-example/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client'

import { ReactElement } from 'react'
import { useRouter } from 'next/navigation'

import Lazy from '@/components/Lazy/Lazy.lazy'
import {
Expand All @@ -14,16 +15,27 @@ import useAppSelector from '@/redux/selectors/useAppSelector/useAppSelector'
export default function Page(): ReactElement {
const count = useAppSelector((state) => state.counterReducer.value)
const dispatch = useAppDispatch()
const { push } = useRouter()

return (
<main style={{ maxWidth: 1200, marginInline: 'auto', padding: 20 }}>
<div style={{ marginBottom: '4rem', textAlign: 'center' }}>
<h1>STATE REDUX</h1>
<h4 style={{ marginBottom: 16 }}>{count}</h4>
<button onClick={() => dispatch(increment())}>increment</button>
<button onClick={() => dispatch(decrement())} style={{ marginInline: 16 }}>
decrement
</button>
<button onClick={() => dispatch(reset())}>reset</button>
<button onClick={() => dispatch(reset())} style={{ marginInline: 16 }}>
reset
</button>
<button
onClick={() => {
push('/redux-persist-example')
}}
>
redirect
</button>
{parseInt(count) === 1 && <Lazy />}
</div>
</main>
Expand Down
Loading

0 comments on commit f5ed4ec

Please sign in to comment.