Skip to content

Commit 35e5052

Browse files
Merge branch 'main' into feat/native-to-be-visible
2 parents 4daebff + 8cbace8 commit 35e5052

File tree

4 files changed

+17
-24
lines changed

4 files changed

+17
-24
lines changed

.all-contributorsrc

+9
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@
162162
"contributions": [
163163
"review"
164164
]
165+
},
166+
{
167+
"login": "asimpletune",
168+
"name": "Spencer Scorcelletti",
169+
"avatar_url": "https://avatars.githubusercontent.com/u/2670813?v=4",
170+
"profile": "https://spenc.es",
171+
"contributions": [
172+
"doc"
173+
]
165174
}
166175
],
167176
"contributorsPerLine": 7,

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
2-
[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-)
2+
[![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square)](#contributors-)
33
<!-- ALL-CONTRIBUTORS-BADGE:END -->
44
[![CI](https://github.com/stackbuilders/assertive-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/stackbuilders/assertive-ts/actions/workflows/ci.yml)
55
[![Release](https://github.com/stackbuilders/assertive-ts/actions/workflows/release.yml/badge.svg)](https://github.com/stackbuilders/assertive-ts/actions/workflows/release.yml)
@@ -13,7 +13,7 @@
1313

1414
A type-safe fluent assertion library written in TypeScript and inspired by [Jest](https://jestjs.io/docs/expect) assertions and the popular [AssertJ](https://assertj.github.io/doc/).
1515

16-
This library is designed to work in the browser and in Node.js. It ships with a rich set of expressive and flexible matchers that allows chaining multiple assertions. Assertive.ts is framework agnostic and should be used with a test framework such as [Jest](/docs/jest-tutorial.md), [Mocha](/docs/mocha-tutorial.md), or Ava.
16+
This library is designed to work in Node.js. It ships with a rich set of expressive and flexible matchers that allows chaining multiple assertions. Assertive.ts is framework agnostic and should be used with a test framework such as [Jest](/docs/jest-tutorial.md), [Mocha](/docs/mocha-tutorial.md), or Ava.
1717

1818
**🚨 BREAKING CHANGES:** Since v2, the `@stackbuilders/assertive-ts` package has been renamed to `@assertive-ts/core` so we can group other packages, such as plugins, into the same namespace. Check the [packages](#packages) section for more info.
1919

@@ -142,7 +142,7 @@ For a list of all [Core](https://github.com/stackbuilders/assertive-ts/blob/main
142142

143143
## Test Runner Integration
144144

145-
Assertive.ts works on any JavaScript test runner, both on Node.js and browser environments. Below you can find some example of how to use it on some of the most common test runners:
145+
Assertive.ts works on any JavaScript test runner, in the Node.js environments. Below you can find some example of how to use it on some of the most common test runners:
146146

147147
- [Jest Integration](https://github.com/stackbuilders/assertive-ts/blob/main/docs/jest-tutorial.md)
148148
- [Mocha Integration](https://github.com/stackbuilders/assertive-ts/blob/main/docs/mocha-tutorial.md)
@@ -176,6 +176,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
176176
</tr>
177177
<tr>
178178
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kdquistanchala"><img src="https://avatars.githubusercontent.com/u/51094604?v=4?s=100" width="100px;" alt="Karla Quistanchala"/><br /><sub><b>Karla Quistanchala</b></sub></a><br /><a href="https://github.com/stackbuilders/assertive-ts/pulls?q=is%3Apr+reviewed-by%3Akdquistanchala" title="Reviewed Pull Requests">👀</a></td>
179+
<td align="center" valign="top" width="14.28%"><a href="https://spenc.es"><img src="https://avatars.githubusercontent.com/u/2670813?v=4?s=100" width="100px;" alt="Spencer Scorcelletti"/><br /><sub><b>Spencer Scorcelletti</b></sub></a><br /><a href="https://github.com/stackbuilders/assertive-ts/commits?author=asimpletune" title="Documentation">📖</a></td>
179180
</tr>
180181
</tbody>
181182
</table>

packages/native/src/lib/ElementAssertion.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Assertion, AssertionError } from "@assertive-ts/core";
22
import { get } from "dot-prop-immutable";
3+
import { Children } from "react";
34
import { ReactTestInstance } from "react-test-renderer";
45

5-
import { instanceToString, isEmpty } from "./helpers/helpers";
6+
import { instanceToString } from "./helpers/helpers";
67

78
export class ElementAssertion extends Assertion<ReactTestInstance> {
89
public constructor(actual: ReactTestInstance) {
@@ -87,7 +88,7 @@ export class ElementAssertion extends Assertion<ReactTestInstance> {
8788
});
8889

8990
return this.execute({
90-
assertWhen: isEmpty(this.actual.children),
91+
assertWhen: Children.count(this.actual.props.children) === 0,
9192
error,
9293
invertedError,
9394
});

packages/native/src/lib/helpers/helpers.ts

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
import { ReactTestInstance } from "react-test-renderer";
22

3-
/**
4-
* Checks if a value is empty.
5-
*
6-
* @param value - The value to check.
7-
* @returns `true` if the value is empty, `false` otherwise.
8-
*/
9-
export function isEmpty(value: unknown): boolean {
10-
if (!value) {
11-
return true;
12-
}
13-
14-
if (Array.isArray(value)) {
15-
return value.length === 0;
16-
}
17-
18-
return false;
19-
}
20-
213
/**
224
* Converts a ReactTestInstance to a string representation.
235
*
24-
* @param instance - The ReactTestInstance to convert.
6+
* @param instance The ReactTestInstance to convert.
257
* @returns A string representation of the instance.
268
*/
279
export function instanceToString(instance: ReactTestInstance | null): string {

0 commit comments

Comments
 (0)