Skip to content

Commit

Permalink
nock out API call to extensions registry (firebase#3037)
Browse files Browse the repository at this point in the history
* nock out API call to extensions registry

* -only
  • Loading branch information
bkendall authored Jan 14, 2021
1 parent 10524fc commit cea069c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/test/extensions/updateHelper.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { expect } from "chai";
import * as nock from "nock";
import * as sinon from "sinon";

import { FirebaseError } from "../../error";
import * as updateHelper from "../../extensions/updateHelper";
import * as prompt from "../../prompt";
import { firebaseExtensionsRegistryOrigin } from "../../api";
import * as extensionsApi from "../../extensions/extensionsApi";
import * as extensionsHelper from "../../extensions/extensionsHelper";
import * as prompt from "../../prompt";
import * as resolveSource from "../../extensions/resolveSource";
import * as extensionsApi from "../../extensions/extensionsApi";
import * as updateHelper from "../../extensions/updateHelper";

const SPEC = {
name: "test",
Expand Down Expand Up @@ -143,12 +145,17 @@ describe("updateHelper", () => {
promptStub = sinon.stub(prompt, "promptOnce");
createSourceStub = sinon.stub(extensionsHelper, "createSourceFromLocation");
getInstanceStub = sinon.stub(extensionsApi, "getInstance").resolves(INSTANCE);

// The logic will fetch the extensions registry, but it doesn't need to receive anything.
nock(firebaseExtensionsRegistryOrigin).get("/extensions.json").reply(200, {});
});

afterEach(() => {
promptStub.restore();
createSourceStub.restore();
getInstanceStub.restore();

nock.cleanAll();
});

it("should return the correct source name for a valid local source", async () => {
Expand Down Expand Up @@ -190,12 +197,17 @@ describe("updateHelper", () => {
promptStub = sinon.stub(prompt, "promptOnce");
createSourceStub = sinon.stub(extensionsHelper, "createSourceFromLocation");
getInstanceStub = sinon.stub(extensionsApi, "getInstance").resolves(INSTANCE);

// The logic will fetch the extensions registry, but it doesn't need to receive anything.
nock(firebaseExtensionsRegistryOrigin).get("/extensions.json").reply(200, {});
});

afterEach(() => {
promptStub.restore();
createSourceStub.restore();
getInstanceStub.restore();

nock.cleanAll();
});

it("should return the correct source name for a valid url source", async () => {
Expand Down

0 comments on commit cea069c

Please sign in to comment.