Skip to content

Commit cea069c

Browse files
authored
nock out API call to extensions registry (#3037)
* nock out API call to extensions registry * -only
1 parent 10524fc commit cea069c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/test/extensions/updateHelper.spec.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { expect } from "chai";
2+
import * as nock from "nock";
23
import * as sinon from "sinon";
34

45
import { FirebaseError } from "../../error";
5-
import * as updateHelper from "../../extensions/updateHelper";
6-
import * as prompt from "../../prompt";
6+
import { firebaseExtensionsRegistryOrigin } from "../../api";
7+
import * as extensionsApi from "../../extensions/extensionsApi";
78
import * as extensionsHelper from "../../extensions/extensionsHelper";
9+
import * as prompt from "../../prompt";
810
import * as resolveSource from "../../extensions/resolveSource";
9-
import * as extensionsApi from "../../extensions/extensionsApi";
11+
import * as updateHelper from "../../extensions/updateHelper";
1012

1113
const SPEC = {
1214
name: "test",
@@ -143,12 +145,17 @@ describe("updateHelper", () => {
143145
promptStub = sinon.stub(prompt, "promptOnce");
144146
createSourceStub = sinon.stub(extensionsHelper, "createSourceFromLocation");
145147
getInstanceStub = sinon.stub(extensionsApi, "getInstance").resolves(INSTANCE);
148+
149+
// The logic will fetch the extensions registry, but it doesn't need to receive anything.
150+
nock(firebaseExtensionsRegistryOrigin).get("/extensions.json").reply(200, {});
146151
});
147152

148153
afterEach(() => {
149154
promptStub.restore();
150155
createSourceStub.restore();
151156
getInstanceStub.restore();
157+
158+
nock.cleanAll();
152159
});
153160

154161
it("should return the correct source name for a valid local source", async () => {
@@ -190,12 +197,17 @@ describe("updateHelper", () => {
190197
promptStub = sinon.stub(prompt, "promptOnce");
191198
createSourceStub = sinon.stub(extensionsHelper, "createSourceFromLocation");
192199
getInstanceStub = sinon.stub(extensionsApi, "getInstance").resolves(INSTANCE);
200+
201+
// The logic will fetch the extensions registry, but it doesn't need to receive anything.
202+
nock(firebaseExtensionsRegistryOrigin).get("/extensions.json").reply(200, {});
193203
});
194204

195205
afterEach(() => {
196206
promptStub.restore();
197207
createSourceStub.restore();
198208
getInstanceStub.restore();
209+
210+
nock.cleanAll();
199211
});
200212

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

0 commit comments

Comments
 (0)