Skip to content

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

883 B
Raw Blame
import { isLogTooLarge } from '../logReport'

const makeLines = (count: number) =>
  Array.from({ length: count }, (_, index) => `line ${index}`).join('\n')

describe('isLogTooLarge', () => {
  it('switches to download after 500 lines', () => {
    expect(isLogTooLarge(makeLines(499))).toBe(false)
    expect(isLogTooLarge(makeLines(500))).toBe(false)
    expect(isLogTooLarge(makeLines(501))).toBe(true)
    expect(isLogTooLarge(`${makeLines(500)}\n`)).toBe(false)
    expect(isLogTooLarge(`${makeLines(501)}\n`)).toBe(true)
  })

  it('switches to download above one million characters', () => {
    expect(isLogTooLarge('a'.repeat(999_999))).toBe(false)
    expect(isLogTooLarge('a'.repeat(1_000_000))).toBe(false)
    expect(isLogTooLarge('a'.repeat(1_000_001))).toBe(true)
  })

  it('keeps an empty log in copy mode', () => {
    expect(isLogTooLarge('')).toBe(false)
  })
})