d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
/**
|
|
* @vitest-environment node
|
|
*/
|
|
import { describe, expect, it } from 'vitest'
|
|
import { appendBrexArrayParam, appendBrexPagination, toBrexDateTime } from '@/tools/brex/utils'
|
|
|
|
describe('toBrexDateTime', () => {
|
|
it('strips a Z suffix by converting to naive UTC', () => {
|
|
expect(toBrexDateTime('2026-01-01T00:00:00Z')).toBe('2026-01-01T00:00:00')
|
|
expect(toBrexDateTime('2026-01-01T12:30:45.123Z')).toBe('2026-01-01T12:30:45')
|
|
})
|
|
|
|
it('converts timezone offsets to UTC before stripping', () => {
|
|
expect(toBrexDateTime('2026-01-01T02:00:00+02:00')).toBe('2026-01-01T00:00:00')
|
|
expect(toBrexDateTime('2025-12-31T19:00:00-05:00')).toBe('2026-01-01T00:00:00')
|
|
})
|
|
|
|
it('passes through timestamps without a timezone unchanged', () => {
|
|
expect(toBrexDateTime('2026-01-01T00:00:00')).toBe('2026-01-01T00:00:00')
|
|
expect(toBrexDateTime('2026-01-01T00:00:00.000')).toBe('2026-01-01T00:00:00.000')
|
|
})
|
|
|
|
it('passes through unparseable values unchanged', () => {
|
|
expect(toBrexDateTime('not-a-date-Z')).toBe('not-a-date-Z')
|
|
})
|
|
})
|
|
|
|
describe('appendBrexArrayParam', () => {
|
|
it('appends repeated params from a comma-separated value, trimming entries', () => {
|
|
const query = new URLSearchParams()
|
|
appendBrexArrayParam(query, 'status[]', ' APPROVED, SETTLED ,, ')
|
|
expect(query.getAll('status[]')).toEqual(['APPROVED', 'SETTLED'])
|
|
})
|
|
|
|
it('does nothing for an empty value', () => {
|
|
const query = new URLSearchParams()
|
|
appendBrexArrayParam(query, 'status[]', undefined)
|
|
expect(query.toString()).toBe('')
|
|
})
|
|
})
|
|
|
|
describe('appendBrexPagination', () => {
|
|
it('appends cursor and limit only when present', () => {
|
|
const query = new URLSearchParams()
|
|
appendBrexPagination(query, { cursor: 'abc', limit: '10' })
|
|
expect(query.get('cursor')).toBe('abc')
|
|
expect(query.get('limit')).toBe('10')
|
|
|
|
const empty = new URLSearchParams()
|
|
appendBrexPagination(empty, {})
|
|
expect(empty.toString()).toBe('')
|
|
})
|
|
})
|