mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-08-28 05:25:25 +00:00
Some checks are pending
CodeQL / Analyze (python) (push) Waiting to run
Gitleaks / gitleaks (push) Waiting to run
Publish / Classify release event (push) Waiting to run
Publish / RC guard (marker + release-PR skip) (push) Blocked by required conditions
Publish / Publish to npm (push) Blocked by required conditions
Trivy Image Scan / Trivy (gitnexus-cli) (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-web) (push) Waiting to run
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
Publish / ci (push) Blocked by required conditions
Publish / Build & Push RC Docker images (push) Blocked by required conditions
Scorecard / Scorecard analysis (push) Waiting to run
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { isValidQueryParams } from '../../src/core/lbug/query-params.js';
|
|
|
|
describe('isValidQueryParams', () => {
|
|
it('accepts plain objects', () => {
|
|
expect(isValidQueryParams({})).toBe(true);
|
|
expect(isValidQueryParams({ name: 'main', limit: 10 })).toBe(true);
|
|
expect(isValidQueryParams({ enabled: true, score: null })).toBe(true);
|
|
expect(isValidQueryParams(Object.create(null))).toBe(true);
|
|
});
|
|
|
|
it('rejects null and arrays', () => {
|
|
expect(isValidQueryParams(null)).toBe(false);
|
|
expect(isValidQueryParams([])).toBe(false);
|
|
});
|
|
|
|
it('rejects primitives', () => {
|
|
expect(isValidQueryParams('x')).toBe(false);
|
|
expect(isValidQueryParams(1)).toBe(false);
|
|
expect(isValidQueryParams(false)).toBe(false);
|
|
expect(isValidQueryParams(undefined)).toBe(false);
|
|
});
|
|
|
|
it('rejects non-plain objects and non-scalar values', () => {
|
|
expect(isValidQueryParams(new Date())).toBe(false);
|
|
expect(isValidQueryParams(new Map())).toBe(false);
|
|
expect(isValidQueryParams({ nested: { value: 1 } })).toBe(false);
|
|
expect(isValidQueryParams({ list: ['x'] })).toBe(false);
|
|
});
|
|
});
|