import { describe, expect, it } from 'vitest';

import {
  buildPluginPageQueryParams,
  buildPluginToolPageQueryParams,
} from './plugin-query';

describe('plugin query params', () => {
  it('uses the unified keyword for plugin name and description search', () => {
    expect(buildPluginPageQueryParams('7', ' 1213 ')).toEqual({
      category: '7',
      keyword: '1213',
    });
  });

  it('retains category while clearing the keyword', () => {
    expect(buildPluginPageQueryParams('7', '   ')).toEqual({
      category: '7',
      keyword: undefined,
    });
  });

  it('uses the unified keyword for plugin tool name and description search', () => {
    expect(buildPluginToolPageQueryParams(' HTTP ')).toEqual({
      keyword: 'HTTP',
    });
  });
});
