figma-icon-getter
Version:
A simple solution to get component set icons from Figma
38 lines (37 loc) • 1.59 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const dotenv_1 = __importDefault(require("dotenv"));
dotenv_1.default.config({ path: ".env" });
const lib_1 = require("../lib");
describe("getFigmaIcons", () => {
const mockFileKey = process.env.FIGMA_FILE_KEY || "mock-file-key"; // Use .env value or fallback
const figmaAccessToken = process.env.FIGMA_PAT || "mock-access-token"; // Use .env value or fallback
it("should fetch icons successfully when nodeIds are provided", async () => {
const mockNodeIds = ["2002:25", "3003:45"];
const result = await (0, lib_1.getFigmaIcons)({
figmaAccessToken,
fileKey: mockFileKey,
nodeIds: mockNodeIds,
});
expect(result).toBeDefined();
expect(result).toBeInstanceOf(Array);
});
it("should fetch all icons when nodeIds are not provided", async () => {
const result = await (0, lib_1.getFigmaIcons)({
figmaAccessToken,
fileKey: mockFileKey,
});
expect(result).toBeDefined();
expect(result).toBeInstanceOf(Array);
});
it("should throw an error for invalid fileKey", async () => {
const invalidFileKey = "invalid-key";
await expect((0, lib_1.getFigmaIcons)({
figmaAccessToken,
fileKey: invalidFileKey,
})).rejects.toThrow("An error occurred while fetching Figma file");
});
});