Skip to content

Commit

Permalink
test(testing): fix testing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed May 24, 2024
1 parent 05d7942 commit 2aba3fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- [x] use Mutative
- [ ] Implementing non-invasive injection for DI
- [ ] upgrade react-native v0.73.4
- [ ] support TS 5.0 new decorator(https://github.com/tc39/proposal-decorators)
- [ ] support TS 5.0 new decorator(https://github.com/tc39/proposal-decorators), [more detail](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#differences-with-experimental-legacy-decorators)
- [ ] upgrade inversify v6
- [ ] upgrade react-router v6.22.1
- [ ] upgrade react/react-dom 17.x and 18.x
Expand Down
13 changes: 8 additions & 5 deletions packages/reactant-model/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
createStore,
ReactantMiddleware,
PluginModule,
stateKey,
getRef,
} from 'reactant-module';
import { apply as applyPatches } from 'mutative';
import { model } from '..';
Expand Down Expand Up @@ -218,7 +218,7 @@ test('base model with `useValue` and `enablePatches`', () => {
enablePatches: true,
},
});
const originalTodoState = foo.todo[stateKey]!;
const originalTodoState = getRef(foo.todo).state!;
expect(Object.values(store.getState())).toEqual([{ todoList: [] }]);
expect(actionFn.mock.calls.length).toBe(0);
foo.add('test');
Expand All @@ -240,12 +240,15 @@ test('base model with `useValue` and `enablePatches`', () => {
]);
expect(
applyPatches(originalTodoState, actionFn.mock.calls[0][0]._patches)
).toEqual(foo.todo[stateKey]);
).toEqual(getRef(foo.todo).state);
expect(
applyPatches(originalTodoState, actionFn.mock.calls[0][0]._patches) ===
foo.todo[stateKey]
getRef(foo.todo).state
).toBe(false);
expect(
applyPatches(foo.todo[stateKey]!, actionFn.mock.calls[0][0]._inversePatches)
applyPatches(
getRef(foo.todo).state!,
actionFn.mock.calls[0][0]._inversePatches
)
).toEqual(originalTodoState);
});

0 comments on commit 2aba3fe

Please sign in to comment.