Skip to content

Commit

Permalink
should preserve source
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenyou committed Dec 18, 2024
1 parent 5f72dfe commit 3d59135
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/scalawind/src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,11 @@ export function transformSource(source) {
}

export const scalaSourceTransform = {
scala: (content) => transformSource(content),
scala: (content) => {
const transformed = transformSource(content)
return `${content}
${transformed}
`
},
};
17 changes: 16 additions & 1 deletion packages/scalawind/tests/transform.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test, describe } from "bun:test";
import { transformSource } from "../src/transform";
import { transformSource, scalaSourceTransform } from "../src/transform";

describe("transform scala source", () => {
test("case 1", () => {
Expand Down Expand Up @@ -305,4 +305,19 @@ describe("transform scala source", () => {
const expected = "dark:md:hover:focus:active:group-hover:disabled:bg-red-500";
expect(actual).toBe(expected);
});

test("should preserve original source", () => {
const source = `
div(
cls := "bg-red-500",
tw.flex.items_center
)
`;
const actual = scalaSourceTransform.scala(source)
const expected = `${source}
flex items-center
`
expect(actual).toBe(expected);
})
});

0 comments on commit 3d59135

Please sign in to comment.