import { describe, expect, it } from 'vitest' import { isErrorReportingOff } from './errorReporting' describe('isErrorReportingOff', () => { it('is false without a cookie header', () => { expect(isErrorReportingOff(undefined)).toBe(false) expect(isErrorReportingOff(null)).toBe(false) expect(isErrorReportingOff('')).toBe(false) }) it('is false when the cookie is absent', () => { expect(isErrorReportingOff('a=1; b=2')).toBe(false) }) it('is true when the cookie is off', () => { expect(isErrorReportingOff('pdsmoover_error_reporting=off')).toBe(true) }) it('is false when the cookie has another value', () => { expect(isErrorReportingOff('pdsmoover_error_reporting=on')).toBe(false) expect(isErrorReportingOff('pdsmoover_error_reporting=offline')).toBe(false) }) it('finds the cookie among others, with spaces', () => { expect(isErrorReportingOff('a=1; pdsmoover_error_reporting=off ; b=2')).toBe(true) }) it('does not match a cookie whose name only ends with ours', () => { expect(isErrorReportingOff('xpdsmoover_error_reporting=off')).toBe(false) expect(isErrorReportingOff('a=1; xpdsmoover_error_reporting=off')).toBe(false) }) })