Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 04158b6

Browse files
committed
fixed state.observer.test.ts
1 parent ac9ae74 commit 04158b6

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

packages/core/src/logCodeManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,12 @@ export class LogCodeManager<LogCodeMessagesType extends Object = Object> {
258258
* @param logCodeManager - LogCodeManager to create an extension from.
259259
* @param additionalLogs - Log messages to be added to the created LogCodeManager extensions.
260260
*/
261-
export function assignAdditionalLogs<NewLogCodeMessages, OldLogCodeMessages>(
261+
export function assignAdditionalLogs<
262+
NewLogCodeMessages extends Object,
263+
OldLogCodeMessages extends Object
264+
>(
262265
logCodeManager: LogCodeManager<OldLogCodeMessages>,
263-
additionalLogs: { [key: string]: string }
266+
additionalLogs: Record<string, string>
264267
): LogCodeManager<NewLogCodeMessages> {
265268
const copiedLogCodeManager = new LogCodeManager(
266269
{

packages/core/tests/unit/state/state.observer.test.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ describe('StateObserver Tests', () => {
101101

102102
stateObserver.ingestValue = jest.fn();
103103
computedObserver.ingestValue = jest.fn();
104+
dummyComputed.computeAndIngest = jest.fn();
104105
});
105106

106107
it('should call ingestValue with nextStateValue (default config)', () => {
@@ -140,19 +141,41 @@ describe('StateObserver Tests', () => {
140141
});
141142

142143
it(
143-
"should call 'ingestValue' with computed value " +
144+
"should call 'computeAndIngest' " +
144145
'if Observer belongs to a Computed State (default config)',
145146
async () => {
146-
(dummyComputed as any).computeSync = jest.fn(() => 'computedValue');
147-
148147
computedObserver.ingest();
149148

150-
expect((dummyComputed as any).computeSync).toHaveBeenCalled();
151-
await waitForExpect(() => {
152-
expect(computedObserver.ingestValue).toHaveBeenCalledWith(
153-
'computedValue',
154-
{}
155-
);
149+
expect(dummyComputed.computeAndIngest).toHaveBeenCalledWith({});
150+
}
151+
);
152+
153+
it(
154+
"should call 'computeAndIngest' " +
155+
'if Observer belongs to a Computed State (specific config)',
156+
async () => {
157+
computedObserver.ingest({
158+
force: true,
159+
key: 'coolKey',
160+
storage: false,
161+
sideEffects: {
162+
enabled: false,
163+
},
164+
background: true,
165+
perform: false,
166+
maxTriesToUpdate: 5,
167+
});
168+
169+
expect(dummyComputed.computeAndIngest).toHaveBeenCalledWith({
170+
force: true,
171+
key: 'coolKey',
172+
storage: false,
173+
sideEffects: {
174+
enabled: false,
175+
},
176+
background: true,
177+
perform: false,
178+
maxTriesToUpdate: 5,
156179
});
157180
}
158181
);

0 commit comments

Comments
 (0)