Skip to content

Commit a57e3d3

Browse files
docs: Updated README to Have Types (#36)
* fix: Updating Readme to Have Types * Added typescript syntax to type code blocks * Fixing minor typos As found by @jgoz fixing wether -> whether typo
1 parent 1cf41a4 commit a57e3d3

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ expect.extend({toBeInTheDOM, toHaveClass})
9999

100100
### `toBeInTheDOM`
101101

102+
```typescript
103+
toBeInTheDOM(container?: HTMLElement)
104+
```
105+
102106
This allows you to assert whether an element present in the DOM container or not. If no DOM container is specified it will use the default DOM context.
103107

104108
#### Using the default DOM container
@@ -137,6 +141,10 @@ expect(queryByTestId(container, 'ancestor')).not.toBeInTheDOM(
137141
138142
### `toBeEmpty`
139143

144+
```typescript
145+
toBeEmpty()
146+
```
147+
140148
This allows you to assert whether an element has content or not.
141149

142150
```javascript
@@ -152,6 +160,10 @@ expect(queryByTestId(container, 'not-empty')).not.toBeEmpty()
152160

153161
### `toContainElement`
154162

163+
```typescript
164+
toContainElement(element: HTMLElement)
165+
```
166+
155167
This allows you to assert whether an element contains another element as a descendant or not.
156168

157169
```javascript
@@ -170,6 +182,10 @@ expect(descendant).not.toContainElement(ancestor)
170182

171183
### `toHaveTextContent`
172184

185+
```typescript
186+
toHaveTextContent(text: string | RegExp)
187+
```
188+
173189
This API allows you to check whether the given element has a text content or not.
174190

175191
```javascript
@@ -185,7 +201,11 @@ expect(getByTestId(container, 'count-value')).not.toHaveTextContent('21')
185201

186202
### `toHaveAttribute`
187203

188-
This allows you to check wether the given element has an attribute or not. You
204+
```typescript
205+
toHaveAttribute(attr: string, value?: string)
206+
```
207+
208+
This allows you to check whether the given element has an attribute or not. You
189209
can also optionally check that the attribute has a specific expected value.
190210

191211
```javascript
@@ -207,7 +227,11 @@ expect(getByTestId(container, 'ok-button')).not.toHaveAttribute(
207227

208228
### `toHaveClass`
209229

210-
This allows you to check wether the given element has certain classes within its
230+
```typescript
231+
toHaveClass(...classNames: string[])
232+
```
233+
234+
This allows you to check whether the given element has certain classes within its
211235
`class` attribute.
212236

213237
```javascript
@@ -227,6 +251,10 @@ expect(getByTestId(container, 'delete-button')).not.toHaveClass('btn-link')
227251

228252
### `toHaveStyle`
229253

254+
```typescript
255+
toHaveStyle(css: string)
256+
```
257+
230258
This allows you to check if a certain element has some specific css properties
231259
with specific values applied. It matches only if the element has _all_ the
232260
expected properties applied, not just some of them.
@@ -257,6 +285,10 @@ The usual rules of css precedence apply.
257285

258286
### `toHaveFocus`
259287

288+
```typescript
289+
toHaveFocus()
290+
```
291+
260292
This allows you to assert whether an element has focus or not.
261293

262294
```javascript
@@ -279,6 +311,10 @@ expect(queryByTestId(container, 'focused')).not.toHaveFocus()
279311

280312
### `toBeVisible`
281313

314+
```typescript
315+
toBeVisible()
316+
```
317+
282318
This allows you to check if an element is currently visible to the user.
283319

284320
An element is visible if **all** the following conditions are met:
@@ -308,6 +344,10 @@ expect(container.querySelector('strong')).not.toBeVisible()
308344

309345
### `toBeDisabled`
310346

347+
```typescript
348+
toBeDisabled()
349+
```
350+
311351
This allows you to check whether an element is disabled from the user's perspective.
312352

313353
It matches if the element is a form control and the `disabled` attribute is

0 commit comments

Comments
 (0)