Skip to content

Commit

Permalink
Extensions Tests Improvement (#1789)
Browse files Browse the repository at this point in the history
* speed up extensions tests

* formatting is hard
  • Loading branch information
bkendall committed Nov 13, 2019
1 parent 3be6495 commit 491037c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/test/extensions/extensionsApi.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as _ from "lodash";
import { expect } from "chai";
import * as nock from "nock";
import * as sinon from "sinon";

import * as helpers from "../helpers";
import * as api from "../../api";
import { FirebaseError } from "../../error";

Expand Down Expand Up @@ -43,6 +46,14 @@ const PROJECT_ID = "test-project";
const INSTANCE_ID = "test-extensions-instance";

describe("extensions", () => {
beforeEach(() => {
helpers.mockAuth(sinon);
});

afterEach(() => {
sinon.restore();
});

describe("listInstances", () => {
afterEach(() => {
nock.cleanAll();
Expand Down Expand Up @@ -253,8 +264,6 @@ describe("extensions", () => {
.query({ updateMask: "config.source.name,config.params" })
.reply(200, { name: "operations/abc123" });
nock(api.extensionsOrigin)
.get(`/${VERSION}/operations/abc123`)
.reply(200, { done: false })
.get(`/${VERSION}/operations/abc123`)
.reply(200, { done: true });

Expand All @@ -263,23 +272,21 @@ describe("extensions", () => {
});

expect(nock.isDone()).to.be.true;
}).timeout(2000);
});

it("should not include config.param in updateMask is params aren't changed", async () => {
nock(api.extensionsOrigin)
.patch(`/${VERSION}/projects/${PROJECT_ID}/instances/${INSTANCE_ID}`)
.query({ updateMask: "config.source.name" })
.reply(200, { name: "operations/abc123" });
nock(api.extensionsOrigin)
.get(`/${VERSION}/operations/abc123`)
.reply(200, { done: false })
.get(`/${VERSION}/operations/abc123`)
.reply(200, { done: true });

await extensionsApi.updateInstance(PROJECT_ID, INSTANCE_ID, testSource);

expect(nock.isDone()).to.be.true;
}).timeout(2000);
});

it("should throw a FirebaseError if update returns an error response", async () => {
nock(api.extensionsOrigin)
Expand Down

0 comments on commit 491037c

Please sign in to comment.