Skip to content

Commit

Permalink
Mark storage as persistent
Browse files Browse the repository at this point in the history
  • Loading branch information
scottohara committed Sep 25, 2023
1 parent 1c987b4 commit 6e3452f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ if ("serviceWorker" in window.navigator) {
window.navigator.serviceWorker.register("/service-worker.js").then((registration: ServiceWorkerRegistration): void => window.console.log(`ServiceWorker registration successful with scope: ${registration.scope}`), (error: string): void => window.console.log(`ServiceWorker registration failed: ${error}`));
}

if ("storage" in window.navigator) {
window.navigator.storage.persist().catch((error: string): void => window.console.log(error));
}

// Get a reference to the application controller singleton
const appController = new ApplicationController();

Expand Down
4 changes: 3 additions & 1 deletion src/mocks/window-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import sinon from "sinon";
interface NavigatorMock {
onLine: boolean;
serviceWorker: { register: SinonStub; };
storage: { persist: SinonStub; };
}

class WindowMock {
public readonly navigator: NavigatorMock = {
onLine: true,
serviceWorker: { register: sinon.stub() }
serviceWorker: { register: sinon.stub() },
storage: { persist: sinon.stub() }
};

public readonly alert: SinonStub = sinon.stub();
Expand Down

0 comments on commit 6e3452f

Please sign in to comment.