Skip to content

Commit

Permalink
Draft
Browse files Browse the repository at this point in the history
  • Loading branch information
katydecorah committed Apr 21, 2024
1 parent 544e4b9 commit a7d579b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/font-call.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { GeneratedData } from "./main-app";
import rtlSubsets from "../data/rtl.json";

function fontCallVariant(variants: GeneratedData[number]["variants"]): string {
export function fontCallVariant(
variants: GeneratedData[number]["variants"],
): string {
const [firstVariant] = variants;
if (/\d+/g.test(firstVariant)) {
return `:wght@${firstVariant}`;
Expand Down
21 changes: 21 additions & 0 deletions test/font-call.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { fontCallVariant } from "../components/font-call";

describe("fontCallVariant", () => {
it("should return weight variant when first variant is a number", () => {
const variants = ["400", "italic"];
const result = fontCallVariant(variants);
expect(result).toBe(":wght@400");
});

it('should return italic variant when first variant includes "italic"', () => {
const variants = ["italic", "400"];
const result = fontCallVariant(variants);
expect(result).toBe(":ital@1");
});

it('should return empty string when first variant is neither a number nor "italic"', () => {
const variants = ["regular", "bold"];
const result = fontCallVariant(variants);
expect(result).toBe("");
});
});

0 comments on commit a7d579b

Please sign in to comment.