model-options.test.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import { describe, expect, test } from "bun:test"
  2. import { sortModelOptions } from "../../../../src/component/dialog-model"
  3. describe("sortModelOptions", () => {
  4. test("orders provider-scoped model choices by newest release first", () => {
  5. const sorted = sortModelOptions(
  6. [
  7. { title: "GPT 5.2", releaseDate: "2025-12-11" },
  8. { title: "GPT 5.4", releaseDate: "2026-03-05" },
  9. { title: "GPT 5.1", releaseDate: "2025-11-13" },
  10. ],
  11. true,
  12. )
  13. expect(sorted.map((model) => model.title)).toEqual(["GPT 5.4", "GPT 5.2", "GPT 5.1"])
  14. })
  15. test("orders regular model choices free-first and then newest-first", () => {
  16. const sorted = sortModelOptions(
  17. [
  18. { title: "GLM 5", releaseDate: "2025-07-28" },
  19. { title: "GLM 5.1", releaseDate: "2025-12-09" },
  20. { title: "GLM 5.2", releaseDate: "2026-02-16" },
  21. { title: "Free old", releaseDate: "2024-01-01", footer: "Free" },
  22. { title: "Free new", releaseDate: "2025-01-01", footer: "Free" },
  23. ],
  24. false,
  25. )
  26. expect(sorted.map((model) => model.title)).toEqual(["Free new", "Free old", "GLM 5.2", "GLM 5.1", "GLM 5"])
  27. })
  28. })