Skip to content

Commit

Permalink
Feat: create Merge Key Fn with test code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeong-jj committed Nov 18, 2023
1 parent 6568706 commit 9ba2086
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/transform-to-vanilla/src/transform-keys/merge-key.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const RegExp = /[$_]$/;

// == Interface ================================================================
export function removeSignSimbol(keyStr: string) {
return hasSignSimbol(keyStr) ? keyStr.trim().replace(RegExp, "") : keyStr;
}

// == Utils ====================================================================
function hasSignSimbol(keyStr: string) {
return RegExp.test(keyStr);
}

// == Tests ====================================================================
if (import.meta.vitest) {
const { describe, it, expect } = import.meta.vitest;

describe.concurrent("Remove Key Sign Symbol", () => {
it("No Sign Symbol", () => {
expect(removeSignSimbol("boxShadow")).toBe("boxShadow");
});
it("Has Sign Symbol", () => {
expect(removeSignSimbol("boxShadow$")).toBe("boxShadow");
expect(removeSignSimbol("transform_")).toBe("transform");
});
});
}

0 comments on commit 9ba2086

Please sign in to comment.