fix(types,testing): tighten action context typing and update tests for stricter TypeScript checks
This commit is contained in:
+4
-4
@@ -1,4 +1,4 @@
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartstate from '../ts/index.js';
|
||||
|
||||
type TMyStateParts = 'testStatePart';
|
||||
@@ -39,7 +39,7 @@ tap.test('should select something', async () => {
|
||||
tap.test('should dispatch a state action', async (tools) => {
|
||||
const done = tools.defer();
|
||||
const addFavourite = testStatePart.createAction<string>(async (statePart, payload) => {
|
||||
const currentState = statePart.getState();
|
||||
const currentState = statePart.getState()!;
|
||||
return {
|
||||
...currentState,
|
||||
currentFavorites: [...currentState.currentFavorites, payload],
|
||||
@@ -51,9 +51,9 @@ tap.test('should dispatch a state action', async (tools) => {
|
||||
})
|
||||
.then(() => {
|
||||
done.resolve();
|
||||
});
|
||||
});
|
||||
await testStatePart.dispatchAction(addFavourite, 'my favourite things');
|
||||
expect(testStatePart.getState().currentFavorites).toContain('my favourite things');
|
||||
expect(testStatePart.getState()!.currentFavorites).toContain('my favourite things');
|
||||
await done.promise;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user