Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

689 B
Raw Blame
import { describe, expect, test } from 'vitest';
import { DATA_TYPE, FIELD_LENGTH } from './constants';
import { getStoredStringValue } from './data';

describe('getStoredStringValue', () => {
  test('truncates oversized string values to the storage limit', () => {
    expect(
      getStoredStringValue('x'.repeat(FIELD_LENGTH.stringValue + 25), DATA_TYPE.string),
    ).toHaveLength(FIELD_LENGTH.stringValue);
  });

  test('drops oversized array payloads instead of storing invalid truncated JSON', () => {
    const oversizedArray = JSON.stringify([`x${'y'.repeat(FIELD_LENGTH.stringValue)}`]);

    expect(getStoredStringValue(oversizedArray, DATA_TYPE.array)).toBeNull();
  });
});