A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.
TypeScript amazon-primeelectronepic-games-launcherepic-games-storeepic-storegaminggoggog-galaxyheroic-games-launcherlinuxplay-gamesprotonsteamwine
import { GameInfo } from 'common/types'
import {
closeStoreStatusWarning,
confirmStoreStatus,
useStoreStatusWarning
} from '../StoreStatusWarning'
const game = (
app_name: string,
storeStatus?: GameInfo['storeStatus']
): GameInfo =>
({ app_name, runner: 'steam', title: app_name, storeStatus }) as GameInfo
const shownGame = () => useStoreStatusWarning.getState().gameInfo?.app_name
describe('confirmStoreStatus', () => {
afterEach(() => closeStoreStatusWarning(false))
it('skips the warning for games still on the store', async () => {
await expect(confirmStoreStatus(game('available'))).resolves.toBe(true)
await expect(confirmStoreStatus(undefined)).resolves.toBe(true)
expect(shownGame()).toBeUndefined()
})
it('proceeds on agree and remembers the game', async () => {
const pending = confirmStoreStatus(game('agreed', 'removed'))
expect(shownGame()).toBe('agreed')
closeStoreStatusWarning(true)
await expect(pending).resolves.toBe(true)
expect(shownGame()).toBeUndefined()
// Acknowledged once per session
await expect(confirmStoreStatus(game('agreed', 'removed'))).resolves.toBe(
true
)
expect(shownGame()).toBeUndefined()
})
it('stops on cancel and asks again next time', async () => {
const pending = confirmStoreStatus(game('cancelled', 'delisted'))
closeStoreStatusWarning(false)
await expect(pending).resolves.toBe(false)
void confirmStoreStatus(game('cancelled', 'delisted'))
expect(shownGame()).toBe('cancelled')
})
it('cancels the open warning when another game asks', async () => {
const first = confirmStoreStatus(game('first', 'removed'))
const second = confirmStoreStatus(game('second', 'delisted'))
await expect(first).resolves.toBe(false)
expect(shownGame()).toBe('second')
closeStoreStatusWarning(true)
await expect(second).resolves.toBe(true)
// First game was never acknowledged
void confirmStoreStatus(game('first', 'removed'))
expect(shownGame()).toBe('first')
})
})