Skip to content

Commit

Permalink
Add tests for state migration from 3 to 7
Browse files Browse the repository at this point in the history
  • Loading branch information
2624789 committed Apr 15, 2024
1 parent a5a1f53 commit 014ff99
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion __tests__/persistent-storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,46 @@ it("returns default when schema is not present", async () => {
expect(state).toEqual(defaultLocalStorageState)
})

it("migrates instance from 3 to 7 ", async () => {
const state3 = {
schemaVersion: 3,
hasShownStableSatsWelcome: true,
isUsdDisabled: true,
galoyInstance: { id: "Main", name: "Blink" },
galoyAuthToken: "token",
isAnalyticsEnabled: false,
}

const state7 = {
schemaVersion: 7,
galoyInstance: { id: "Main" },
}

const res = await migrateAndGetLocalStorageState(state3)

expect(res).toStrictEqual(state7)
})

it("migrates unknown instance from 3 to 7 ", async () => {
const state3 = {
schemaVersion: 3,
hasShownStableSatsWelcome: true,
isUsdDisabled: true,
galoyInstance: { id: "Main", name: "Unknown" },
galoyAuthToken: "token",
isAnalyticsEnabled: false,
}

const state7 = {
schemaVersion: 7,
galoyInstance: { id: "Main" },
}

const res = await migrateAndGetLocalStorageState(state3)

expect(res).toStrictEqual(state7)
})

it("migrates Blink instance from 4 to 7 ", async () => {
const state4 = {
schemaVersion: 4,
Expand Down Expand Up @@ -117,7 +157,7 @@ it("migrates Custom instance from 4 to 7", async () => {

const state7 = {
schemaVersion: 7,
galoyInstance: { id: "Custom" },
galoyInstance: { id: "Custom", name: "Custom" },
}

const res = await migrateAndGetLocalStorageState(state4)
Expand Down

0 comments on commit 014ff99

Please sign in to comment.