Files
webstudio/apps/builder/app/shared/webstudio-data-migrator.test.ts
T
Bogdan Chadkin 23034dad25 feat: add global system variable in builder (#4896)
Closes https://github.com/webstudio-is/webstudio/issues/4166

Now system is global variable and can be accessed in slots.

Legacy one can be deleted

<img width="264" alt="image"
src="https://github.com/user-attachments/assets/1c1d60f5-6be2-4871-9970-3593e3e7c08a"
/>
2025-02-23 01:46:21 +07:00

55 lines
1.5 KiB
TypeScript

import { expect, test } from "vitest";
import type { WebstudioData } from "@webstudio-is/sdk";
import { createDefaultPages } from "@webstudio-is/project-build";
import type { StyleProperty } from "@webstudio-is/css-engine";
import { migrateWebstudioDataMutable } from "./webstudio-data-migrator";
const emptyData: WebstudioData = {
pages: createDefaultPages({
rootInstanceId: "rootInstanceId",
}),
assets: new Map(),
dataSources: new Map(),
resources: new Map(),
instances: new Map(),
props: new Map(),
breakpoints: new Map(),
styleSources: new Map(),
styleSourceSelections: new Map(),
styles: new Map(),
};
test("expand overflow shorthand", () => {
const data = structuredClone(emptyData);
data.styles.set("base:local:overflow::hover", {
breakpointId: "base",
styleSourceId: "local",
state: ":hover",
property: "overflow" as StyleProperty,
value: {
type: "tuple",
value: [
{ type: "keyword", value: "auto" },
{ type: "keyword", value: "hidden" },
],
},
});
migrateWebstudioDataMutable(data);
expect(Array.from(data.styles.values())).toEqual([
{
breakpointId: "base",
property: "overflowX",
state: ":hover",
styleSourceId: "local",
value: { type: "keyword", value: "auto" },
},
{
breakpointId: "base",
property: "overflowY",
state: ":hover",
styleSourceId: "local",
value: { type: "keyword", value: "hidden" },
},
]);
});