Skip to content

Commit

Permalink
switch to default sandbox instead of creating a custom one
Browse files Browse the repository at this point in the history
  • Loading branch information
akdombrowski committed Oct 23, 2024
1 parent f20932a commit 8c64a95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
23 changes: 11 additions & 12 deletions test/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ import sinon from "sinon";
import { expect } from "chai";

describe("#cli()", function () {
let sandbox;
let log;
let err;
before(function () {
sandbox = sinon.createSandbox();
log = sandbox.spy(console, "log");
err = sandbox.spy(console, "error");
});

beforeEach(function () {
log.resetHistory();
err.resetHistory();
log = sinon.spy(console, "log");
err = sinon.spy(console, "error");
});

afterEach(function () {
// doesn't seem to want to cleanup from hooks.js
sinon.restore();
})

describe("using help", function () {
context("when argument is -h", function () {
it("shows the help screen", function () {
Expand All @@ -43,7 +42,7 @@ describe("#cli()", function () {
context("when 'clipboard' contains a jwt", function () {
it("decodes the jwt", async function () {
const myCli = cli;
const cliSpy = sandbox.spy(myCli);
const cliSpy = sinon.spy(myCli);

const clipboard =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
Expand Down Expand Up @@ -92,7 +91,7 @@ describe("#cli()", function () {

context("when input doesn't contain a '.'", function () {
it("logs an error: \"Need at least one '.'\"", async function () {
const spy = sandbox.spy(cli);
const spy = sinon.spy(cli);
const clipboard = "abc";

await spy(clipboard, null);
Expand All @@ -107,7 +106,7 @@ describe("#cli()", function () {
describe("#base64urlEncode()", function () {
context("when first given argument is -b", function () {
it("properly base64url encodes the input", async function () {
const spy = sandbox.spy(cli);
const spy = sinon.spy(cli);

const b64u =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
Expand Down Expand Up @@ -165,7 +164,7 @@ describe("#cli()", function () {

context("when first given argument is --base64url", function () {
it("properly base64url encodes the input", async function () {
const spy = sandbox.spy(cli);
const spy = sinon.spy(cli);

const b64u =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
Expand Down
4 changes: 2 additions & 2 deletions test/hooks.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { restore } from "sinon";
// import sinon from "sinon";

// Restores the default sandbox after every test
const mochaHooks = {
afterEach() {
restore();
sinon.restore();
},
};

Expand Down

0 comments on commit 8c64a95

Please sign in to comment.