pluginStoreOrder.test.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { describe, expect, it } from "vitest";
  2. import { parsePluginStoreOrder } from "../src/pluginStoreOrder.js";
  3. describe("parsePluginStoreOrder", () => {
  4. it("归一化两级列表,重复项取首次,模式互不继承", () => {
  5. expect(
  6. parsePluginStoreOrder({
  7. code: {
  8. categoryOrder: [" other ", "productivity", "other"],
  9. pluginOrder: { productivity: [" b@official ", "a@official", "b@official"] },
  10. },
  11. }),
  12. ).toEqual({
  13. code: {
  14. categoryOrder: ["other", "productivity"],
  15. pluginOrder: { productivity: ["b@official", "a@official"] },
  16. },
  17. });
  18. });
  19. it.each([undefined, null, false, "bad", []])("缺失/无效配置回退默认 %j", (value) => {
  20. expect(parsePluginStoreOrder(value)).toBeNull();
  21. });
  22. it("无效模式隔离,不影响另一模式", () => {
  23. expect(
  24. parsePluginStoreOrder({
  25. code: { categoryOrder: [3] },
  26. work: { categoryOrder: [] },
  27. }),
  28. ).toEqual({ work: { categoryOrder: [] } });
  29. expect(parsePluginStoreOrder({ code: { pluginOrder: { productivity: [""] } } })).toEqual({});
  30. });
  31. });