UNPKG

near-protocol-rewards

Version:

A transparent, metric-based rewards system for NEAR projects

63 lines (62 loc) 2.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const sdk_1 = require("../../src/sdk"); const errors_1 = require("../../src/types/errors"); describe("SDK Integration", () => { let sdk; beforeEach(() => { sdk = new sdk_1.GitHubRewardsSDK({ githubToken: process.env.GITHUB_TOKEN, githubRepo: process.env.TEST_GITHUB_REPO, isTestMode: true, }); }); it("should validate GitHub token", async () => { if (!process.env.GITHUB_TOKEN) { console.warn("Skipping test: No GitHub token provided"); return; } const testSdk = new sdk_1.GitHubRewardsSDK({ githubToken: process.env.GITHUB_TOKEN, githubRepo: process.env.TEST_GITHUB_REPO || "jbarnes850/near-protocol-rewards", isTestMode: true, }); await expect(testSdk.startTracking()).resolves.not.toThrow(); console.log("✅ GitHub token is valid and has correct permissions"); }); it("should handle invalid configuration", () => { expect(() => { new sdk_1.GitHubRewardsSDK({ githubToken: "", githubRepo: "invalid-repo-format", isTestMode: true, }); }).toThrow(errors_1.BaseError); }); it("should initialize with valid configuration", () => { const validSdk = new sdk_1.GitHubRewardsSDK({ githubToken: "valid-token", githubRepo: "owner/repo", isTestMode: true, }); expect(validSdk).toBeInstanceOf(sdk_1.GitHubRewardsSDK); }); it("should require githubRepo in owner/repo format", () => { expect(() => { new sdk_1.GitHubRewardsSDK({ githubToken: "valid-token", githubRepo: "invalid-format", isTestMode: true, }); }).toThrow(/githubRepo must be in format "owner\/repo"/); }); it("should require non-empty githubToken", () => { expect(() => { new sdk_1.GitHubRewardsSDK({ githubToken: "", githubRepo: "owner/repo", isTestMode: true, }); }).toThrow(/githubToken is required/); }); });