|
1 | 1 | import { expect } from "chai"; |
| 2 | +import * as nock from "nock"; |
2 | 3 | import * as sinon from "sinon"; |
3 | 4 |
|
4 | 5 | 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"; |
7 | 8 | import * as extensionsHelper from "../../extensions/extensionsHelper"; |
| 9 | +import * as prompt from "../../prompt"; |
8 | 10 | import * as resolveSource from "../../extensions/resolveSource"; |
9 | | -import * as extensionsApi from "../../extensions/extensionsApi"; |
| 11 | +import * as updateHelper from "../../extensions/updateHelper"; |
10 | 12 |
|
11 | 13 | const SPEC = { |
12 | 14 | name: "test", |
@@ -143,12 +145,17 @@ describe("updateHelper", () => { |
143 | 145 | promptStub = sinon.stub(prompt, "promptOnce"); |
144 | 146 | createSourceStub = sinon.stub(extensionsHelper, "createSourceFromLocation"); |
145 | 147 | 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, {}); |
146 | 151 | }); |
147 | 152 |
|
148 | 153 | afterEach(() => { |
149 | 154 | promptStub.restore(); |
150 | 155 | createSourceStub.restore(); |
151 | 156 | getInstanceStub.restore(); |
| 157 | + |
| 158 | + nock.cleanAll(); |
152 | 159 | }); |
153 | 160 |
|
154 | 161 | it("should return the correct source name for a valid local source", async () => { |
@@ -190,12 +197,17 @@ describe("updateHelper", () => { |
190 | 197 | promptStub = sinon.stub(prompt, "promptOnce"); |
191 | 198 | createSourceStub = sinon.stub(extensionsHelper, "createSourceFromLocation"); |
192 | 199 | 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, {}); |
193 | 203 | }); |
194 | 204 |
|
195 | 205 | afterEach(() => { |
196 | 206 | promptStub.restore(); |
197 | 207 | createSourceStub.restore(); |
198 | 208 | getInstanceStub.restore(); |
| 209 | + |
| 210 | + nock.cleanAll(); |
199 | 211 | }); |
200 | 212 |
|
201 | 213 | it("should return the correct source name for a valid url source", async () => { |
|
0 commit comments