Update Expectations of `update` method (#7119)
* Update Expectations of `update` method Change `update` to return current state when `shouldUpdate` returns false. * Delete Accidental Tests
This commit is contained in:
parent
6ddf87bc72
commit
c3e114e36f
|
@ -48,7 +48,7 @@ export class FakeGlobalState<T> implements GlobalState<T> {
|
||||||
? await firstValueFrom(options.combineLatestWith.pipe(timeout(options.msTimeout)))
|
? await firstValueFrom(options.combineLatestWith.pipe(timeout(options.msTimeout)))
|
||||||
: null;
|
: null;
|
||||||
if (!options.shouldUpdate(current, combinedDependencies)) {
|
if (!options.shouldUpdate(current, combinedDependencies)) {
|
||||||
return;
|
return current;
|
||||||
}
|
}
|
||||||
const newState = configureState(current, combinedDependencies);
|
const newState = configureState(current, combinedDependencies);
|
||||||
this.stateSubject.next(newState);
|
this.stateSubject.next(newState);
|
||||||
|
@ -77,7 +77,7 @@ export class FakeUserState<T> implements UserState<T> {
|
||||||
? await firstValueFrom(options.combineLatestWith.pipe(timeout(options.msTimeout)))
|
? await firstValueFrom(options.combineLatestWith.pipe(timeout(options.msTimeout)))
|
||||||
: null;
|
: null;
|
||||||
if (!options.shouldUpdate(current, combinedDependencies)) {
|
if (!options.shouldUpdate(current, combinedDependencies)) {
|
||||||
return;
|
return current;
|
||||||
}
|
}
|
||||||
const newState = configureState(current, combinedDependencies);
|
const newState = configureState(current, combinedDependencies);
|
||||||
this.stateSubject.next(newState);
|
this.stateSubject.next(newState);
|
||||||
|
|
|
@ -301,7 +301,7 @@ describe("DefaultActiveUserState", () => {
|
||||||
await awaitAsync();
|
await awaitAsync();
|
||||||
|
|
||||||
expect(diskStorageService.mock.save).not.toHaveBeenCalled();
|
expect(diskStorageService.mock.save).not.toHaveBeenCalled();
|
||||||
expect(result).toBe(undefined);
|
expect(result).toBeNull();
|
||||||
expect(emissions).toEqual([null]);
|
expect(emissions).toEqual([null]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ export class DefaultActiveUserState<T> implements ActiveUserState<T> {
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (!options.shouldUpdate(currentState, combinedDependencies)) {
|
if (!options.shouldUpdate(currentState, combinedDependencies)) {
|
||||||
return;
|
return currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newState = configureState(currentState, combinedDependencies);
|
const newState = configureState(currentState, combinedDependencies);
|
||||||
|
|
|
@ -145,7 +145,7 @@ describe("DefaultGlobalState", () => {
|
||||||
|
|
||||||
expect(diskStorageService.mock.save).not.toHaveBeenCalled();
|
expect(diskStorageService.mock.save).not.toHaveBeenCalled();
|
||||||
expect(emissions).toEqual([null]); // Initial value
|
expect(emissions).toEqual([null]); // Initial value
|
||||||
expect(result).toBeUndefined();
|
expect(result).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should provide the update callback with the current State", async () => {
|
it("should provide the update callback with the current State", async () => {
|
||||||
|
|
|
@ -85,7 +85,7 @@ export class DefaultGlobalState<T> implements GlobalState<T> {
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (!options.shouldUpdate(currentState, combinedDependencies)) {
|
if (!options.shouldUpdate(currentState, combinedDependencies)) {
|
||||||
return;
|
return currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newState = configureState(currentState, combinedDependencies);
|
const newState = configureState(currentState, combinedDependencies);
|
||||||
|
|
|
@ -156,7 +156,7 @@ describe("DefaultSingleUserState", () => {
|
||||||
|
|
||||||
expect(diskStorageService.mock.save).not.toHaveBeenCalled();
|
expect(diskStorageService.mock.save).not.toHaveBeenCalled();
|
||||||
expect(emissions).toEqual([null]); // Initial value
|
expect(emissions).toEqual([null]); // Initial value
|
||||||
expect(result).toBeUndefined();
|
expect(result).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should provide the update callback with the current State", async () => {
|
it("should provide the update callback with the current State", async () => {
|
||||||
|
|
|
@ -91,7 +91,7 @@ export class DefaultSingleUserState<T> implements SingleUserState<T> {
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (!options.shouldUpdate(currentState, combinedDependencies)) {
|
if (!options.shouldUpdate(currentState, combinedDependencies)) {
|
||||||
return;
|
return currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newState = configureState(currentState, combinedDependencies);
|
const newState = configureState(currentState, combinedDependencies);
|
||||||
|
|
Loading…
Reference in New Issue