mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-09 05:26:24 +09:00
Ref https://github.com/webstudio-is/webstudio/issues/1536 https://github.com/webstudio-is/webstudio/issues/3399 Refactored image control to maintain styles internally. Important to not this is the first repeated style control. It accepts property and additionally index of repeated style. Would work with future sections like mask-image We can also improve it to support both singular and repeated styles in the future. <img width="231" alt="Screenshot 2024-09-10 at 19 52 17" src="https://github.com/user-attachments/assets/a0d27b1b-ae72-4454-b31e-d1f5af3bc4d1">
41 lines
803 B
TypeScript
41 lines
803 B
TypeScript
import { expect, test } from "@jest/globals";
|
|
import { removeByMutable, repeatUntil } from "./array-utils";
|
|
|
|
test("removeByMutable", () => {
|
|
const array = [
|
|
{ param: 1 },
|
|
{ param: 2 },
|
|
{ param: 3 },
|
|
{ param: 4 },
|
|
{ param: 5 },
|
|
{ param: 6 },
|
|
];
|
|
removeByMutable(array, (item) => item.param % 2 === 1);
|
|
expect(array).toMatchInlineSnapshot(`
|
|
[
|
|
{
|
|
"param": 2,
|
|
},
|
|
{
|
|
"param": 4,
|
|
},
|
|
{
|
|
"param": 6,
|
|
},
|
|
]
|
|
`);
|
|
removeByMutable(array, (item) => item.param !== 4);
|
|
expect(array).toMatchInlineSnapshot(`
|
|
[
|
|
{
|
|
"param": 4,
|
|
},
|
|
]
|
|
`);
|
|
});
|
|
|
|
test("repeatUntil", () => {
|
|
expect(repeatUntil([1, 2, 3], 5)).toEqual([1, 2, 3, 1, 2]);
|
|
expect(repeatUntil([1, 2, 3], 1)).toEqual([1, 2, 3]);
|
|
});
|