Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

1.1 KB
Raw Blame
import { describe, expect, it } from 'vitest';

import { parseRecipients } from './pulse-recipients';

describe('parseRecipients', () => {
  it('keeps valid addresses, trimmed', () => {
    expect(parseRecipients([' [email protected]', '[email protected] '])).toEqual({
      valid: ['[email protected]', '[email protected]'],
      invalid: [],
    });
  });

  it('returns invalid addresses instead of dropping them', () => {
    expect(parseRecipients(['[email protected]', 'team@example', 'no-at-sign'])).toEqual({
      valid: ['[email protected]'],
      invalid: ['team@example', 'no-at-sign'],
    });
  });

  it('reports an all-invalid list as invalid, not as empty', () => {
    expect(parseRecipients(['team@example'])).toEqual({ valid: [], invalid: ['team@example'] });
  });

  it('ignores blank entries and non-strings', () => {
    expect(parseRecipients(['', '  ', 42, null, '[email protected]'])).toEqual({
      valid: ['[email protected]'],
      invalid: [],
    });
  });

  it('treats an empty list as empty', () => {
    expect(parseRecipients([])).toEqual({ valid: [], invalid: [] });
  });
});