Skip to content

Commit ea0954e

Browse files
committed
Move src/test/*.spec.ts tests (#7318)
1 parent f0e9276 commit ea0954e

38 files changed

+104
-103
lines changed

src/test/accountExporter.spec.ts renamed to src/accountExporter.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as nock from "nock";
44
import * as os from "os";
55
import * as sinon from "sinon";
66

7-
import { validateOptions, serialExportUsers } from "../accountExporter";
7+
import { validateOptions, serialExportUsers } from "./accountExporter";
88

99
describe("accountExporter", () => {
1010
describe("validateOptions", () => {

src/test/accountImporter.spec.ts renamed to src/accountImporter.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as nock from "nock";
22
import { expect } from "chai";
33

4-
import { googleOrigin } from "../api";
4+
import { googleOrigin } from "./api";
55

6-
import * as accountImporter from "../accountImporter";
6+
import * as accountImporter from "./accountImporter";
77

88
describe("accountImporter", () => {
99
before(() => {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { expect } from "chai";
22

3-
import * as utils from "../utils";
3+
import * as utils from "./utils";
44

55
describe("api", () => {
66
beforeEach(() => {
77
// The api module resolves env var statically so we need to
88
// do lazy imports and clear the import each time.
9-
delete require.cache[require.resolve("../api")];
9+
delete require.cache[require.resolve("./api")];
1010
});
1111

1212
afterEach(() => {
@@ -18,21 +18,21 @@ describe("api", () => {
1818
});
1919

2020
after(() => {
21-
delete require.cache[require.resolve("../api")];
21+
delete require.cache[require.resolve("./api")];
2222
});
2323

2424
it("should override with FIRESTORE_URL", () => {
2525
process.env.FIRESTORE_URL = "http://foobar.com";
2626

27-
const api = require("../api");
27+
const api = require("./api");
2828
expect(api.firestoreOrigin()).to.eq("http://foobar.com");
2929
});
3030

3131
it("should prefer FIRESTORE_EMULATOR_HOST to FIRESTORE_URL", () => {
3232
process.env.FIRESTORE_EMULATOR_HOST = "localhost:8080";
3333
process.env.FIRESTORE_URL = "http://foobar.com";
3434

35-
const api = require("../api");
35+
const api = require("./api");
3636
expect(api.firestoreOriginOrEmulator()).to.eq("http://localhost:8080");
3737
});
3838
});

src/test/apiv2.spec.ts renamed to src/apiv2.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import * as nock from "nock";
44
import AbortController from "abort-controller";
55
const proxySetup = require("proxy");
66

7-
import { Client } from "../apiv2";
8-
import { FirebaseError } from "../error";
9-
import { streamToString, stringToStream } from "../utils";
7+
import { Client } from "./apiv2";
8+
import { FirebaseError } from "./error";
9+
import { streamToString, stringToStream } from "./utils";
1010

1111
describe("apiv2", () => {
1212
beforeEach(() => {
1313
// The api module has package variables that we don't want sticking around.
14-
delete require.cache[require.resolve("../apiv2")];
14+
delete require.cache[require.resolve("./apiv2")];
1515

1616
nock.cleanAll();
1717
});
1818

1919
after(() => {
20-
delete require.cache[require.resolve("../apiv2")];
20+
delete require.cache[require.resolve("./apiv2")];
2121
});
2222

2323
describe("request", () => {

src/test/archiveDirectory.spec.ts renamed to src/archiveDirectory.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { resolve } from "path";
22
import { expect } from "chai";
3-
import { FirebaseError } from "../error";
3+
import { FirebaseError } from "./error";
44

5-
import { archiveDirectory } from "../archiveDirectory";
5+
import { archiveDirectory } from "./archiveDirectory";
66

7-
const SOME_FIXTURE_DIRECTORY = resolve(__dirname, "./fixtures/config-imports");
7+
const SOME_FIXTURE_DIRECTORY = resolve(__dirname, "./test/fixtures/config-imports");
88

99
describe("archiveDirectory", () => {
1010
it("should archive happy little directories", async () => {

src/test/auth.spec.ts renamed to src/auth.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
getGlobalDefaultAccount,
88
getProjectDefaultAccount,
99
selectAccount,
10-
} from "../auth";
11-
import { configstore } from "../configstore";
12-
import { Account } from "../types/auth";
10+
} from "./auth";
11+
import { configstore } from "./configstore";
12+
import { Account } from "./types/auth";
1313

1414
describe("auth", () => {
1515
const sandbox: sinon.SinonSandbox = sinon.createSandbox();

src/test/checkMinRequiredVersion.spec.ts renamed to src/checkMinRequiredVersion.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect } from "chai";
2-
import { configstore } from "../configstore";
2+
import { configstore } from "./configstore";
33
import * as sinon from "sinon";
44

5-
import { checkMinRequiredVersion } from "../checkMinRequiredVersion";
5+
import { checkMinRequiredVersion } from "./checkMinRequiredVersion";
66
import Sinon from "sinon";
77

88
describe("checkMinRequiredVersion", () => {

src/test/checkValidTargetFilters.spec.ts renamed to src/checkValidTargetFilters.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { expect } from "chai";
22

3-
import { Options } from "../options";
4-
import { RC } from "../rc";
3+
import { Options } from "./options";
4+
import { RC } from "./rc";
55

6-
import { checkValidTargetFilters } from "../checkValidTargetFilters";
6+
import { checkValidTargetFilters } from "./checkValidTargetFilters";
77

88
const SAMPLE_OPTIONS: Options = {
99
cwd: "/",

src/test/command.spec.ts renamed to src/command.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect } from "chai";
22
import * as nock from "nock";
33

4-
import { Command, validateProjectId } from "../command";
5-
import { FirebaseError } from "../error";
4+
import { Command, validateProjectId } from "./command";
5+
import { FirebaseError } from "./error";
66

77
describe("Command", () => {
88
let command: Command;

src/test/config.spec.ts renamed to src/config.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { expect } from "chai";
22
import * as path from "path";
33

4-
import { Config } from "../config";
4+
import { Config } from "./config";
55

66
function fixtureDir(name: string): string {
7-
return path.resolve(__dirname, "./fixtures/" + name);
7+
return path.resolve(__dirname, "./test/fixtures/" + name);
88
}
99

1010
describe("Config", () => {
1111
describe("#load", () => {
1212
it("should load a cjson file when configPath is specified", () => {
1313
const config = Config.load({
1414
cwd: __dirname,
15-
configPath: "./fixtures/valid-config/firebase.json",
15+
configPath: "./test/fixtures/valid-config/firebase.json",
1616
});
1717
expect(config).to.not.be.null;
1818
if (config) {

src/test/defaultCredentials.spec.ts renamed to src/defaultCredentials.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import * as fs from "fs";
44
import * as path from "path";
55
import * as os from "os";
66

7-
import * as api from "../api";
8-
import { configstore } from "../configstore";
9-
import * as defaultCredentials from "../defaultCredentials";
10-
import { getGlobalDefaultAccount } from "../auth";
11-
import { Account } from "../types/auth";
7+
import * as api from "./api";
8+
import { configstore } from "./configstore";
9+
import * as defaultCredentials from "./defaultCredentials";
10+
import { getGlobalDefaultAccount } from "./auth";
11+
import { Account } from "./types/auth";
1212

1313
describe("defaultCredentials", () => {
1414
const sandbox: sinon.SinonSandbox = sinon.createSandbox();

src/test/downloadUtils.spec.ts renamed to src/downloadUtils.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { readFileSync } from "fs-extra";
33
import * as nock from "nock";
44
import { gunzipSync, gzipSync } from "zlib";
55

6-
import { downloadToTmp } from "../downloadUtils";
7-
import { FirebaseError } from "../error";
6+
import { downloadToTmp } from "./downloadUtils";
7+
import { FirebaseError } from "./error";
88

99
describe("downloadToTmp", () => {
1010
it("should download a file", async () => {

src/test/ensureApiEnabled.spec.ts renamed to src/ensureApiEnabled.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from "chai";
22
import * as nock from "nock";
33

4-
import { check, ensure, POLL_SETTINGS } from "../ensureApiEnabled";
4+
import { check, ensure, POLL_SETTINGS } from "./ensureApiEnabled";
55

66
const FAKE_PROJECT_ID = "my_project";
77
const FAKE_API = "myapi.googleapis.com";

src/test/error.spec.ts renamed to src/error.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { FirebaseError } from "../error";
2+
import { FirebaseError } from "./error";
33

44
describe("error", () => {
55
describe("FirebaseError", () => {

src/test/experiments.spec.ts renamed to src/experiments.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { enableExperimentsFromCliEnvVariable, isEnabled, setEnabled } from "../experiments";
2+
import { enableExperimentsFromCliEnvVariable, isEnabled, setEnabled } from "./experiments";
33

44
describe("experiments", () => {
55
let originalCLIState = process.env.FIREBASE_CLI_EXPERIMENTS;

src/test/fetchWebSetup.spec.ts renamed to src/fetchWebSetup.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { expect } from "chai";
22
import * as nock from "nock";
33
import * as sinon from "sinon";
44

5-
import { configstore } from "../configstore";
6-
import { fetchWebSetup, getCachedWebSetup } from "../fetchWebSetup";
7-
import { firebaseApiOrigin } from "../api";
8-
import { FirebaseError } from "../error";
5+
import { configstore } from "./configstore";
6+
import { fetchWebSetup, getCachedWebSetup } from "./fetchWebSetup";
7+
import { firebaseApiOrigin } from "./api";
8+
import { FirebaseError } from "./error";
99

1010
describe("fetchWebSetup module", () => {
1111
before(() => {

src/test/filterTargets.spec.ts renamed to src/filterTargets.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from "chai";
2-
import { filterTargets } from "../filterTargets";
3-
import { Options } from "../options";
4-
import { RC } from "../rc";
2+
import { filterTargets } from "./filterTargets";
3+
import { Options } from "./options";
4+
import { RC } from "./rc";
55

66
const SAMPLE_OPTIONS: Options = {
77
cwd: "/",

src/test/firebaseConfigValidate.spec.ts renamed to src/firebaseConfigValidate.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
2-
import { getValidator } from "../firebaseConfigValidate";
3-
import { FirebaseConfig } from "../firebaseConfig";
2+
import { getValidator } from "./firebaseConfigValidate";
3+
import { FirebaseConfig } from "./firebaseConfig";
44

55
describe("firebaseConfigValidate", () => {
66
it("should accept a basic, valid config", () => {

src/test/fsAsync.spec.ts renamed to src/fsAsync.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as os from "os";
55
import * as path from "path";
66
import { sync as rimraf } from "rimraf";
77

8-
import * as fsAsync from "../fsAsync";
8+
import * as fsAsync from "./fsAsync";
99

1010
// These tests work on the following directory structure:
1111
// <basedir>

src/test/fsutils.spec.ts renamed to src/fsutils.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
22

3-
import * as fsutils from "../fsutils";
3+
import * as fsutils from "./fsutils";
44

55
describe("fsutils", () => {
66
describe("fileExistsSync", () => {

src/test/functional.spec.ts renamed to src/functional.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect } from "chai";
22
import { flatten } from "lodash";
3-
import { SameType } from "../metaprogramming";
3+
import { SameType } from "./metaprogramming";
44

5-
import * as f from "../functional";
5+
import * as f from "./functional";
66

77
describe("functional", () => {
88
describe("flatten", () => {

src/test/functionsConfig.spec.ts renamed to src/functionsConfig.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
22

3-
import * as functionsConfig from "../functionsConfig";
3+
import * as functionsConfig from "./functionsConfig";
44

55
describe("config.parseSetArgs", () => {
66
it("should throw if a reserved namespace is used", () => {

src/hosting/config.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect } from "chai";
2+
import * as path from "path";
23
import { FirebaseError } from "../error";
34
import { HostingConfig, HostingMultiple, HostingSingle } from "../firebaseConfig";
45

@@ -24,8 +25,8 @@ function options(
2425
return targetsToSites?.[name] || [];
2526
},
2627
},
27-
cwd: __dirname + "/../fixtures/simplehosting",
28-
configPath: __dirname + "/../fixtures/simplehosting/firebase.json",
28+
cwd: path.resolve(__dirname, "../test/fixtures/simplehosting"),
29+
configPath: path.resolve(__dirname, "../test/fixtures/simplehosting/firebase.json"),
2930
...base,
3031
};
3132
}

src/test/listFiles.spec.ts renamed to src/listFiles.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { expect } from "chai";
22
import { resolve } from "path";
33

4-
import { listFiles } from "../listFiles";
4+
import { listFiles } from "./listFiles";
55

66
describe("listFiles", () => {
77
// for details, see the file structure and firebase.json in test/fixtures/ignores
88
it("should ignore firebase-debug.log, specified ignores, and nothing else", () => {
9-
const fileNames = listFiles(resolve(__dirname, "./fixtures/ignores"), [
9+
const fileNames = listFiles(resolve(__dirname, "./test/fixtures/ignores"), [
1010
"**/.*",
1111
"firebase.json",
1212
"ignored.txt",
@@ -16,7 +16,7 @@ describe("listFiles", () => {
1616
});
1717

1818
it("should allow us to not specify additional ignores", () => {
19-
const fileNames = listFiles(resolve(__dirname, "./fixtures/ignores"));
19+
const fileNames = listFiles(resolve(__dirname, "./test/fixtures/ignores"));
2020
expect(fileNames.sort()).to.have.members([
2121
".hiddenfile",
2222
"firebase.json",

src/test/localFunction.spec.ts renamed to src/localFunction.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect } from "chai";
22

3-
import LocalFunction from "../localFunction";
4-
import { EmulatedTriggerDefinition } from "../emulator/functionsEmulatorShared";
5-
import { FunctionsEmulatorShell } from "../emulator/functionsEmulatorShell";
3+
import LocalFunction from "./localFunction";
4+
import { EmulatedTriggerDefinition } from "./emulator/functionsEmulatorShared";
5+
import { FunctionsEmulatorShell } from "./emulator/functionsEmulatorShell";
66

77
const EMULATED_TRIGGER: EmulatedTriggerDefinition = {
88
id: "fn",

src/test/metapgrogramming.spec.ts renamed to src/metapgrogramming.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
DeepOmit,
88
RequireKeys,
99
DeepExtract,
10-
} from "../metaprogramming";
10+
} from "./metaprogramming";
1111

1212
describe("metaprogramming", () => {
1313
it("can calcluate recursive keys", () => {

src/test/operation-poller.spec.ts renamed to src/operation-poller.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { expect } from "chai";
22
import * as nock from "nock";
33
import * as sinon from "sinon";
44

5-
import { FirebaseError } from "../error";
6-
import { OperationPollerOptions, pollOperation } from "../operation-poller";
7-
import TimeoutError from "../throttler/errors/timeout-error";
5+
import { FirebaseError } from "./error";
6+
import { OperationPollerOptions, pollOperation } from "./operation-poller";
7+
import TimeoutError from "./throttler/errors/timeout-error";
88

99
const TEST_ORIGIN = "https://firebasedummy.googleapis.com.com";
1010
const VERSION = "v1";

src/test/profileReport.spec.ts renamed to src/profileReport.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { expect } from "chai";
22

33
import * as path from "path";
44
import * as stream from "stream";
5-
import { extractReadableIndex, formatNumber, ProfileReport } from "../profileReport";
5+
import { extractReadableIndex, formatNumber, ProfileReport } from "./profileReport";
66

77
function combinerFunc(obj1: any, obj2: any): any {
88
return { count: obj1.count + obj2.count };
99
}
1010

11-
const fixturesDir = path.resolve(__dirname, "./fixtures");
11+
const fixturesDir = path.resolve(__dirname, "./test/fixtures");
1212

1313
function newReport() {
1414
const input = path.resolve(fixturesDir, "profiler-data/sample.json");

src/test/projectUtils.spec.ts renamed to src/projectUtils.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { expect } from "chai";
22
import * as sinon from "sinon";
33

4-
import { needProjectNumber, needProjectId, getAliases, getProjectId } from "../projectUtils";
5-
import * as projects from "../management/projects";
6-
import { RC } from "../rc";
4+
import { needProjectNumber, needProjectId, getAliases, getProjectId } from "./projectUtils";
5+
import * as projects from "./management/projects";
6+
import { RC } from "./rc";
77

88
describe("getProjectId", () => {
99
it("should prefer projectId, falling back to project", () => {

0 commit comments

Comments
 (0)