mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix getting initial value of sync box
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
326c8a950c
commit
55b27de10a
@ -105,6 +105,11 @@ describe("encourage user to update when sufficient time passed since update was
|
||||
expect(button).toHaveAttribute("data-warning-level", "light");
|
||||
});
|
||||
|
||||
// TODO: Implement after starting main and renderer is separated in ApplicationBuilder
|
||||
xit("given closing the application window, when starting the application window again, still shows the button", () => {
|
||||
expect(button).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe("given some time passes, when checking for updates again", () => {
|
||||
beforeEach(() => {
|
||||
advanceFakeTime(daysToMilliseconds(2));
|
||||
|
||||
@ -7,6 +7,10 @@ import { beforeFrameStartsInjectionToken } from "../../before-frame-starts/befor
|
||||
import syncBoxInitialValueChannelInjectable from "../../../common/utils/sync-box/sync-box-initial-value-channel.injectable";
|
||||
import createSyncBoxStateInjectable from "../../../common/utils/sync-box/sync-box-state.injectable";
|
||||
import { requestFromChannelInjectionToken } from "../../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { runInAction } from "mobx";
|
||||
import type { SyncBox } from "../../../common/utils/sync-box/sync-box-injection-token";
|
||||
import { syncBoxInjectionToken } from "../../../common/utils/sync-box/sync-box-injection-token";
|
||||
import assert from "assert";
|
||||
|
||||
const provideInitialValuesForSyncBoxesInjectable = getInjectable({
|
||||
id: "provide-initial-values-for-sync-boxes",
|
||||
@ -14,14 +18,24 @@ const provideInitialValuesForSyncBoxesInjectable = getInjectable({
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
const syncBoxInitialValueChannel = di.inject(syncBoxInitialValueChannelInjectable);
|
||||
const setSyncBoxState = (id: string, state: any) => di.inject(createSyncBoxStateInjectable, id).set(state);
|
||||
|
||||
const syncBoxes = di.injectMany(syncBoxInjectionToken);
|
||||
|
||||
const setSyncBoxState = (syncBox: SyncBox<any>, state: any) =>
|
||||
di.inject(createSyncBoxStateInjectable, syncBox.id).set(state);
|
||||
|
||||
return {
|
||||
run: async () => {
|
||||
const initialValues = await requestFromChannel(syncBoxInitialValueChannel);
|
||||
|
||||
initialValues.forEach(({ id, value }) => {
|
||||
setSyncBoxState(id, value);
|
||||
runInAction(() => {
|
||||
initialValues.forEach(({ id, value }) => {
|
||||
const syncBox = syncBoxes.find((box) => box.id === id);
|
||||
|
||||
assert(syncBox);
|
||||
|
||||
setSyncBoxState(syncBox, value);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user