From 8b1b50d35e59dcbd3eff44af9c09904221eb3838 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:44:06 +0000 Subject: [PATCH] [autofix.ci] apply automated fixes --- .../next-yak/runtime/__tests__/attrs.test.tsx | 89 ++++++++++++------- .../runtime/__tests__/styled.test.tsx | 28 ++++-- packages/next-yak/runtime/mocks/styled.ts | 15 ++-- 3 files changed, 83 insertions(+), 49 deletions(-) diff --git a/packages/next-yak/runtime/__tests__/attrs.test.tsx b/packages/next-yak/runtime/__tests__/attrs.test.tsx index e15134da..07648460 100644 --- a/packages/next-yak/runtime/__tests__/attrs.test.tsx +++ b/packages/next-yak/runtime/__tests__/attrs.test.tsx @@ -91,9 +91,11 @@ it("should not call a function passed to attrs as an object value", () => { }); it("defaultProps are merged into what function attrs receives", () => { - const Comp = (styled("button") as typeof styled.button).attrs((props) => ({ - "data-color": props.color, - }))``; + const Comp = (styled("button") as typeof styled.button).attrs( + (props) => ({ + "data-color": props.color, + }), + )``; Comp.defaultProps = { color: "red", @@ -110,7 +112,9 @@ it("defaultProps are merged into what function attrs receives", () => { }); it("pass props to the attr function", () => { - const Comp = (styled("button") as typeof styled.button).attrs<{ $submit?: boolean }>((p) => ({ + const Comp = (styled("button") as typeof styled.button).attrs<{ + $submit?: boolean; + }>((p) => ({ type: p.$submit ? "submit" : "button", }))``; @@ -131,7 +135,9 @@ it("pass props to the attr function", () => { }); it("should replace props with attrs", () => { - const Comp = (styled("button") as typeof styled.button).attrs<{ $submit?: boolean }>((p) => ({ + const Comp = (styled("button") as typeof styled.button).attrs<{ + $submit?: boolean; + }>((p) => ({ type: p.$submit ? "submit" : "button", tabIndex: 0, }))``; @@ -175,7 +181,9 @@ it("should merge className", () => { }); it("should merge className from folded attrs", () => { - const Inner = (styled("div") as typeof styled.div).attrs({ className: "foo" })``; + const Inner = (styled("div") as typeof styled.div).attrs({ + className: "foo", + })``; const Comp = styled(Inner).attrs(() => ({ className: "meow nya", @@ -191,9 +199,11 @@ it("should merge className from folded attrs", () => { }); it("should merge className even if its a function", () => { - const Comp = (styled("div") as typeof styled.div).attrs<{ $purr?: boolean }>((p) => ({ - className: `meow ${p.$purr ? "purr" : "nya"}`, - }))``; + const Comp = (styled("div") as typeof styled.div).attrs<{ $purr?: boolean }>( + (p) => ({ + className: `meow ${p.$purr ? "purr" : "nya"}`, + }), + )``; expect(TestRenderer.create().toJSON()).toMatchInlineSnapshot(`
{ }); it("should work with data and aria attributes", () => { - const Comp = (styled("div") as typeof styled.div).attrs(() => ({ - "data-foo": "bar", - "aria-label": "A simple FooBar", - }))``; + const Comp = (styled("div") as typeof styled.div).attrs( + () => ({ + "data-foo": "bar", + "aria-label": "A simple FooBar", + }), + )``; expect(TestRenderer.create().toJSON()).toMatchInlineSnapshot(`
{ }); it('should shallow merge "style" prop + attr instead of overwriting', () => { - const Paragraph = (styled("p") as typeof styled.p).attrs<{ $fontScale?: number }>((p) => ({ + const Paragraph = (styled("p") as typeof styled.p).attrs<{ + $fontScale?: number; + }>((p) => ({ style: { ...p.style, fontSize: `${p.$fontScale}em`, @@ -407,7 +421,9 @@ it("does not pass transient props to HTML element", () => { }); it.skip('should apply given "as" prop to the progressive type', () => { - const Comp = (styled("div") as typeof styled.div).attrs<{ as?: any }>({ as: "video" as const })``; + const Comp = (styled("div") as typeof styled.div).attrs<{ as?: any }>({ + as: "video" as const, + })``; //@ts-expect-error expect(TestRenderer.create().toJSON()).toMatchInlineSnapshot(` @@ -421,12 +437,13 @@ it.skip('should apply given "as" prop to the progressive type', () => { // our own tests it("should remap props", () => { - const Comp = (styled("button") as typeof styled.button).attrs<{ primary?: boolean; $submit?: boolean }>( - (p) => ({ - type: p.$submit ? "submit" : "button", - $primary: p.primary, - }), - )<{ $primary?: boolean }>``; + const Comp = (styled("button") as typeof styled.button).attrs<{ + primary?: boolean; + $submit?: boolean; + }>((p) => ({ + type: p.$submit ? "submit" : "button", + $primary: p.primary, + }))<{ $primary?: boolean }>``; expect(TestRenderer.create().toJSON()).toMatchInlineSnapshot(`