Skip to content

A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.

738 B
Raw Blame
import { serializeInstallInfoError } from '../utils'

describe('serializeInstallInfoError', () => {
  it('keeps an Error message', () => {
    expect(serializeInstallInfoError(new Error('gogdl exited with 1'))).toBe(
      'gogdl exited with 1'
    )
  })

  it('keeps a string', () => {
    expect(serializeInstallInfoError('no credentials')).toBe('no credentials')
  })

  it('serializes a plain object', () => {
    expect(serializeInstallInfoError({ code: 1, detail: 'bad manifest' })).toBe(
      '{"code":1,"detail":"bad manifest"}'
    )
  })

  it('falls back to Unknown error', () => {
    expect(serializeInstallInfoError(undefined)).toBe('Unknown error')
    expect(serializeInstallInfoError({})).toBe('Unknown error')
  })
})