From c1b59dc3db6000da1cd6f2b05a7b7f646b063dfd Mon Sep 17 00:00:00 2001 From: Gregor Martynus Date: Sun, 3 Nov 2019 08:50:51 -0800 Subject: [PATCH] test: adapt for @octokit/core v2 --- test/smoke.test.ts | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/test/smoke.test.ts b/test/smoke.test.ts index 4b5c6e08..642913f3 100644 --- a/test/smoke.test.ts +++ b/test/smoke.test.ts @@ -1,12 +1,31 @@ -// These environment variables to exist on import time -process.env.GITHUB_TOKEN = "secret123"; -process.env.GITHUB_ACTION = "test"; - import { Octokit } from "../src"; describe("Smoke test", () => { - it("is a function", () => { + it("happy path", () => { + process.env.GITHUB_TOKEN = "secret123"; + process.env.GITHUB_ACTION = "test"; + expect(Octokit).toBeInstanceOf(Function); expect(() => new Octokit()).not.toThrow(); }); + + it("throws if GITHUB_TOKEN is not set", () => { + delete process.env.GITHUB_TOKEN; + process.env.GITHUB_ACTION = "test"; + + expect(Octokit).toBeInstanceOf(Function); + expect(() => new Octokit()).toThrow( + "[@octokit/auth-action] `GITHUB_TOKEN` environment variable is not set. See https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret" + ); + }); + + it("throws if GITHUB_ACTION is not set", () => { + process.env.GITHUB_TOKEN = "secret123"; + delete process.env.GITHUB_ACTION; + + expect(Octokit).toBeInstanceOf(Function); + expect(() => new Octokit()).toThrow( + "[@octokit/auth-action] `GITHUB_ACTION` environment variable is not set. @octokit/auth-action is meant to be used in GitHub Actions only." + ); + }); });