From 552df3155baa09332b01959483e647fc9be50429 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Fri, 20 May 2022 14:26:43 +0300 Subject: [PATCH] Simplify test Signed-off-by: Janne Savolainen --- ...g-update-from-update-channels.test.ts.snap | 32 +--------- ...alling-update-from-update-channels.test.ts | 63 ++++++------------- 2 files changed, 19 insertions(+), 76 deletions(-) diff --git a/src/behaviours/application-update/__snapshots__/installing-update-from-update-channels.test.ts.snap b/src/behaviours/application-update/__snapshots__/installing-update-from-update-channels.test.ts.snap index 87df586d63..d6399de891 100644 --- a/src/behaviours/application-update/__snapshots__/installing-update-from-update-channels.test.ts.snap +++ b/src/behaviours/application-update/__snapshots__/installing-update-from-update-channels.test.ts.snap @@ -1,36 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`installing update from update channels given no update channel selection is stored, when started renders 1`] = ` - -
-
-
- -`; - -exports[`installing update from update channels given no update channel selection is stored, when started when user checks for updates renders 1`] = ` - -
-
-
- -`; - -exports[`installing update from update channels given no update channel selection is stored, when started when user checks for updates when new update is discovered renders 1`] = ` - -
-
-
- -`; - -exports[`installing update from update channels given no update channel selection is stored, when started when user checks for updates when new update is discovered when download succeeds renders 1`] = ` +exports[`installing update from update channels when started renders 1`] = `
{ }); }); - describe("given no update channel selection is stored, when started", () => { + describe("when started", () => { let rendered: RenderResult; let checkForUpdates: () => Promise; @@ -85,50 +85,6 @@ describe("installing update from update channels", () => { expect(rendered.baseElement).toMatchSnapshot(); }); - describe("when user checks for updates", () => { - let checkForUpdatesPromise: Promise; - - beforeEach(async () => { - checkForUpdatesPromise = checkForUpdates(); - }); - - it('checks for updates from "latest" update channel by default', () => { - expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith( - updateChannels.latest, - { allowDowngrade: true }, - ); - }); - - it("renders", () => { - expect(rendered.baseElement).toMatchSnapshot(); - }); - - describe("when new update is discovered", () => { - beforeEach(async () => { - await checkForPlatformUpdatesMock.resolve({ - updateWasDiscovered: true, - version: "some-version", - }); - - await checkForUpdatesPromise; - }); - - it("renders", () => { - expect(rendered.baseElement).toMatchSnapshot(); - }); - - describe("when download succeeds", () => { - beforeEach(async () => { - await downloadPlatformUpdateMock.resolve({ downloadWasSuccessful: true }); - }); - - it("renders", () => { - expect(rendered.baseElement).toMatchSnapshot(); - }); - }); - }); - }); - describe('given update channel "alpha" is selected, when checking for updates', () => { let selectedUpdateChannel: { value: IComputedValue; @@ -309,6 +265,23 @@ describe("installing update from update channels", () => { expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.latest, expect.any(Object)); }); + it('given no update channel selection is stored and currently using stable release, when user checks for updates, checks for updates from "latest" update channel by default', async () => { + applicationBuilder.beforeApplicationStart(({ mainDi }) => { + mainDi.override(appVersionInjectable, () => "1.0.0"); + }); + + await applicationBuilder.render(); + + const checkForUpdates = applicationBuilder.dis.mainDi.inject(checkForUpdatesInjectable); + + checkForUpdates(); + + expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith( + updateChannels.latest, + { allowDowngrade: true }, + ); + }); + it('given no update channel selection is stored and currently using alpha release, when checking for updates, checks for updates from "alpha" channel', async () => { applicationBuilder.beforeApplicationStart(({ mainDi }) => { mainDi.override(appVersionInjectable, () => "1.0.0-alpha");