Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve docs readability #1931

Merged
merged 7 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions docs/guides/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ this means your application logic does not need to be changed or mocked when wri

## Setting Up Zustand for testing

Since Jest and Vitest have slight differences, like Vitest using **ES modules** and Jest using
**CommonJS modules**, you need to keep that in mind if you are using Vitest instead of Jest.
> **Note**: Since Jest and Vitest have slight differences, like Vitest using **ES modules** and Jest using
> **CommonJS modules**, you need to keep that in mind if you are using Vitest instead of Jest.

The mock provided below will enable the relevant test runner to reset the zustand stores after each test.

### Jest

In the next steps we are going to setup our Jest environment in order to mock Zustand
In the next steps we are going to setup our Jest environment in order to mock Zustand.

```ts
// __mocks__/zustand.ts
Expand Down Expand Up @@ -239,7 +241,7 @@ import { Counter } from './counter'

describe('Counter', () => {
test('should render successfully', async () => {
renderCounter()
render(<Counter />)

expect(await screen.findByText(/^1$/)).toBeInTheDocument()
expect(
Expand All @@ -250,7 +252,7 @@ describe('Counter', () => {
test('should increase count by clicking a button', async () => {
const user = userEvent.setup()

renderCounter()
render(<Counter />)

expect(await screen.findByText(/^1$/)).toBeInTheDocument()

Expand All @@ -259,10 +261,6 @@ describe('Counter', () => {
expect(await screen.findByText(/^2$/)).toBeInTheDocument()
})
})

const renderCounter = () => {
return render(<Counter />)
}
```

> **Note**: without [globals configuration](https://vitest.dev/config/#globals) enabled, we need
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ So we have two problems: lack of inference and unsoundness. Lack of inference ca
</details>

<details>
<summary>Why that currying `()(...)`?</summary>
<summary>Why the currying `()(...)`?</summary>

<br/>

Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can try a live demo [here](https://githubbox.com/pmndrs/zustand/tree/main/ex
npm install zustand # or yarn add zustand or pnpm add zustand
```

:warning: This readme is written for JavaScript users. If you are a TypeScript user, don't miss [TypeScript Usage](#typescript-usage).
:warning: This readme is written for JavaScript users. If you are a TypeScript user, be sure to check out our [TypeScript Usage section](#typescript-usage).

## First create a store

Expand Down Expand Up @@ -513,6 +513,7 @@ A more complete TypeScript guide is [here](docs/guides/typescript.md).
- Recommended usage for this unopinionated library: [Flux inspired practice](./docs/guides/flux-inspired-practice.md).
- [Calling actions outside a React event handler in pre-React 18](./docs/guides/event-handler-in-pre-react-18.md).
- [Testing](./docs/guides/testing.md)
- For more, have a look [in the docs folder](./docs/)

## Third-Party Libraries

Expand Down