Skip to content
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
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

10 changes: 10 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Automerge

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
automerge:
uses: Neovici/cfg/.github/workflows/automerge.yml@master
secrets: inherit
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI

on:
push:
branches: [beta, master, main]
pull_request:
branches: [master, main]

permissions:
contents: write
issues: write
pull-requests: write
id-token: write

jobs:
ci:
uses: Neovici/cfg/.github/workflows/forge.yml@master
secrets: inherit
13 changes: 0 additions & 13 deletions .github/workflows/main.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# testing
Testing library utilities

## renderHook

The `renderHook` function allows you to test hooks in isolation for web components using Pion.js.

### Basic Usage

```typescript
import { renderHook } from '@neovici/testing';
import { useState, useCallback } from '@pionjs/pion';

function useCounter() {
const [count, setCount] = useState(0);
const increment = useCallback(() => setCount(count + 1), [count]);
return { count, increment };
}

describe('useCounter', () => {
it('should return initial count', async () => {
const { result } = await renderHook(() => useCounter());
expect(result.current.count).to.equal(0);
});
});
```

### Return Value

The `renderHook` function returns an object with the following properties:

- `result`: The current result of the hook execution
- `rerender(newProps?)`: Re-render the hook with new props
- `unmount()`: Unmount the hook and cleanup
- `nextUpdate(message?, options?)`: Wait for the next update
- `host`: The host element (HTMLElement) for hooks that need direct host access

### Options

- `initialProps`: Initial props to pass to the hook
- `wrapper`: A wrapper function to wrap the hook rendering
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import cfg from '@neovici/cfg/eslint/index.mjs';

export default [
...cfg,
{
ignores: ['dist/', 'coverage/'],
},
{
files: ['test/**/*.test.+(t|j)s'],
rules: {
'@typescript-eslint/no-unused-expressions': 'off',
},
},
];
Loading