telemetry-switch.spec.ts 965 B

1234567891011121314151617181920212223
  1. import { describe, expect, it } from 'vitest'
  2. import { resolveTelemetryPatch } from '../src/app-cli-entry.ts'
  3. describe('resolveTelemetryPatch', () => {
  4. it('keeps telemetry enabled when the switch is unset or empty', () => {
  5. expect(resolveTelemetryPatch(undefined, true)).toBeUndefined()
  6. expect(resolveTelemetryPatch('', true)).toBeUndefined()
  7. })
  8. it('disables on ANY non-empty value, including falsy-looking ones', () => {
  9. for (const value of ['1', '0', 'false', 'no']) {
  10. expect(resolveTelemetryPatch(value, true)).toEqual({ id: 'telemetry-otel', disabled: true })
  11. }
  12. })
  13. it('fails loud when the switch is set but the row is absent', () => {
  14. expect(() => resolveTelemetryPatch('1', false)).toThrow('DSH_TELEMETRY_DISABLED is set but row "telemetry-otel" is not in this composition')
  15. })
  16. it('ignores a missing row while the switch is unset', () => {
  17. expect(resolveTelemetryPatch(undefined, false)).toBeUndefined()
  18. })
  19. })