Skip to content

Commit

Permalink
[INTERNAL] TypeScript: Fix import paths in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Aug 27, 2024
1 parent 0d29cc5 commit 9dc300e
Show file tree
Hide file tree
Showing 73 changed files with 233 additions and 230 deletions.
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
build/** -linguist-generated=false
lib/build/** linguist-generated=false
lib/** linguist-vendored=false
lib/** linguist-generated=false
lib/** linguist-generated=false
src/build/** linguist-generated=false
src/** linguist-vendored=false
src/** linguist-generated=false
20 changes: 10 additions & 10 deletions test/lib/build/ProjectBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sinonGlobal from "sinon";
import path from "node:path";
import esmock from "esmock";
import {setLogLevel} from "@ui5/logger";
import OutputStyleEnum from "../../../lib/build/helpers/ProjectBuilderOutputStyle.js";
import OutputStyleEnum from "../../../src/build/helpers/ProjectBuilderOutputStyle.js";

function noop() {}

Expand Down Expand Up @@ -72,7 +72,7 @@ test.beforeEach(async (t) => {
}),
};

t.context.ProjectBuilder = await esmock("../../../lib/build/ProjectBuilder.js");
t.context.ProjectBuilder = await esmock("../../../src/build/ProjectBuilder.js");
});

test.afterEach.always((t) => {
Expand Down Expand Up @@ -272,7 +272,7 @@ test.serial("build: Multiple projects", async (t) => {
t.is(moduleName, "ProjectBuilder", "BuildLogger created with expected moduleName");
return buildLoggerMock;
}
const ProjectBuilder = await esmock("../../../lib/build/ProjectBuilder.js", {
const ProjectBuilder = await esmock("../../../src/build/ProjectBuilder.js", {
"@ui5/logger/internal/loggers/Build": CreateBuildLoggerMock,
});

Expand Down Expand Up @@ -440,8 +440,8 @@ test.serial("_getProjectFilter with dependencyIncludes", async (t) => {
includedDependencies: ["project.b", "project.c"],
excludedDependencies: ["project.d", "project.e", "project.a"],
});
const ProjectBuilder = await esmock("../../../lib/build/ProjectBuilder.js", {
"../../../lib/build/helpers/composeProjectList.js": composeProjectListStub,
const ProjectBuilder = await esmock("../../../src/build/ProjectBuilder.js", {
"../../../src/build/helpers/composeProjectList.js": composeProjectListStub,
});

const builder = new ProjectBuilder({graph, taskRepository});
Expand Down Expand Up @@ -471,8 +471,8 @@ test.serial("_getProjectFilter with explicit include/exclude", async (t) => {
includedDependencies: ["project.b", "project.c"],
excludedDependencies: ["project.d", "project.e", "project.a"],
});
const ProjectBuilder = await esmock("../../../lib/build/ProjectBuilder.js", {
"../../../lib/build/helpers/composeProjectList.js": composeProjectListStub,
const ProjectBuilder = await esmock("../../../src/build/ProjectBuilder.js", {
"../../../src/build/helpers/composeProjectList.js": composeProjectListStub,
});

const builder = new ProjectBuilder({graph, taskRepository});
Expand Down Expand Up @@ -573,8 +573,8 @@ test.serial("_writeResults: Create build manifest", async (t) => {

const createBuildManifestStub = sinon.stub().returns({build: "manifest"});
const createResourceStub = sinon.stub().returns("build manifest resource");
const ProjectBuilder = await esmock.p("../../../lib/build/ProjectBuilder.js", {
"../../../lib/build/helpers/createBuildManifest.js": createBuildManifestStub,
const ProjectBuilder = await esmock.p("../../../src/build/ProjectBuilder.js", {
"../../../src/build/helpers/createBuildManifest.js": createBuildManifestStub,
"@ui5/fs/resourceFactory": {
createResource: createResourceStub,
},
Expand Down Expand Up @@ -766,7 +766,7 @@ test("instantiate new logger for every ProjectBuilder", async (t) => {

const {graph, taskRepository, sinon} = t.context;
const createBuildLoggerMockSpy = sinon.spy(CreateBuildLoggerMock);
const ProjectBuilder = await esmock("../../../lib/build/ProjectBuilder.js", {
const ProjectBuilder = await esmock("../../../src/build/ProjectBuilder.js", {
"@ui5/logger/internal/loggers/Build": createBuildLoggerMockSpy,
});

Expand Down
2 changes: 1 addition & 1 deletion test/lib/build/TaskRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ test.beforeEach(async (t) => {
.returns("reader collection"),
};

t.context.TaskRunner = await esmock("../../../lib/build/TaskRunner.js", {
t.context.TaskRunner = await esmock("../../../src/build/TaskRunner.js", {
"@ui5/logger": t.context.logger,
"@ui5/fs/resourceFactory": t.context.resourceFactory,
});
Expand Down
2 changes: 1 addition & 1 deletion test/lib/build/definitions/application.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from "ava";
import sinon from "sinon";
import application from "../../../../lib/build/definitions/application.js";
import application from "../../../../src/build/definitions/application.js";

function emptyarray() {
return [];
Expand Down
2 changes: 1 addition & 1 deletion test/lib/build/definitions/library.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from "ava";
import sinon from "sinon";
import library from "../../../../lib/build/definitions/library.js";
import library from "../../../../src/build/definitions/library.js";

function emptyarray() {
return [];
Expand Down
2 changes: 1 addition & 1 deletion test/lib/build/definitions/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from "ava";
import moduleDefinition from "../../../../lib/build/definitions/module.js";
import moduleDefinition from "../../../../src/build/definitions/module.js";

test("Standard build", (t) => {
const tasks = moduleDefinition({});
Expand Down
2 changes: 1 addition & 1 deletion test/lib/build/definitions/themeLibrary.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from "ava";
import sinon from "sinon";
import themeLibrary from "../../../../lib/build/definitions/themeLibrary.js";
import themeLibrary from "../../../../src/build/definitions/themeLibrary.js";

function emptyarray() {
return [];
Expand Down
2 changes: 1 addition & 1 deletion test/lib/build/definitions/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from "ava";
import {enhancePatternWithExcludes} from "../../../../lib/build/definitions/_utils.js";
import {enhancePatternWithExcludes} from "../../../../src/build/definitions/_utils.js";

test("enhancePatternWithExcludes", (t) => {
const patterns = ["/default/pattern", "!/other/pattern"];
Expand Down
4 changes: 2 additions & 2 deletions test/lib/build/helpers/BuildContext.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import test from "ava";
import sinon from "sinon";
import OutputStyleEnum from "../../../../lib/build/helpers/ProjectBuilderOutputStyle.js";
import OutputStyleEnum from "../../../../src/build/helpers/ProjectBuilderOutputStyle.js";

test.afterEach.always((t) => {
sinon.restore();
});

import BuildContext from "../../../../lib/build/helpers/BuildContext.js";
import BuildContext from "../../../../src/build/helpers/BuildContext.js";

test("Missing parameters", (t) => {
const error1 = t.throws(() => {
Expand Down
14 changes: 7 additions & 7 deletions test/lib/build/helpers/ProjectBuildContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.afterEach.always((t) => {
sinon.restore();
});

import ProjectBuildContext from "../../../../lib/build/helpers/ProjectBuildContext.js";
import ProjectBuildContext from "../../../../src/build/helpers/ProjectBuildContext.js";

test("Missing parameters", (t) => {
t.throws(() => {
Expand Down Expand Up @@ -140,7 +140,7 @@ test.serial("getResourceTagCollection", async (t) => {
}
}

const ProjectBuildContext = await esmock("../../../../lib/build/helpers/ProjectBuildContext.js", {
const ProjectBuildContext = await esmock("../../../../src/build/helpers/ProjectBuildContext.js", {
"@ui5/fs/internal/ResourceTagCollection": DummyResourceTagCollection,
});
const projectBuildContext = new ProjectBuildContext({
Expand Down Expand Up @@ -336,8 +336,8 @@ test.serial("getTaskRunner", async (t) => {
}, "TaskRunner created with expected constructor arguments");
}
}
const ProjectBuildContext = await esmock("../../../../lib/build/helpers/ProjectBuildContext.js", {
"../../../../lib/build/TaskRunner.js": TaskRunnerMock,
const ProjectBuildContext = await esmock("../../../../src/build/helpers/ProjectBuildContext.js", {
"../../../../src/build/TaskRunner.js": TaskRunnerMock,
});

const projectBuildContext = new ProjectBuildContext({
Expand Down Expand Up @@ -377,9 +377,9 @@ test.serial("createProjectContext", async (t) => {
t.is(_taskRunner, taskRunner);
}
}
const BuildContext = await esmock("../../../../lib/build/helpers/BuildContext.js", {
"../../../../lib/build/helpers/ProjectBuildContext.js": ProjectContextMock,
"../../../../lib/build/TaskRunner.js": {
const BuildContext = await esmock("../../../../src/build/helpers/BuildContext.js", {
"../../../../src/build/helpers/ProjectBuildContext.js": ProjectContextMock,
"../../../../src/build/TaskRunner.js": {
create: sinon.stub().resolves(taskRunner),
},
});
Expand Down
4 changes: 2 additions & 2 deletions test/lib/build/helpers/TaskUtil.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from "ava";
import sinon from "sinon";
import TaskUtil from "../../../../lib/build/helpers/TaskUtil.js";
import SpecificationVersion from "../../../../lib/specifications/SpecificationVersion.js";
import TaskUtil from "../../../../src/build/helpers/TaskUtil.js";
import SpecificationVersion from "../../../../src/specifications/SpecificationVersion.js";

test.afterEach.always((t) => {
sinon.restore();
Expand Down
4 changes: 2 additions & 2 deletions test/lib/build/helpers/composeProjectList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from "ava";
import sinon from "sinon";
import esmock from "esmock";
import path from "node:path";
import {graphFromObject} from "../../../../lib/graph/graph.js";
import {graphFromObject} from "../../../../src/graph/graph.js";

const __dirname = import.meta.dirname;

Expand All @@ -16,7 +16,7 @@ test.beforeEach(async (t) => {
t.context.log = {
warn: sinon.stub(),
};
t.context.composeProjectList = await esmock("../../../../lib/build/helpers/composeProjectList", {
t.context.composeProjectList = await esmock("../../../../src/build/helpers/composeProjectList", {
"@ui5/logger": {
getLogger: sinon.stub().withArgs("build:helpers:composeProjectList").returns(t.context.log),
},
Expand Down
2 changes: 1 addition & 1 deletion test/lib/build/helpers/composeTaskList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test.beforeEach(async (t) => {
};
const getLoggerStub = sinon.stub().withArgs("build:helpers:composeTaskList").returns(t.context.log);

t.context.composeTaskList = await esmock("../../../../lib/build/helpers/composeTaskList.js", {
t.context.composeTaskList = await esmock("../../../../src/build/helpers/composeTaskList.js", {
"@ui5/logger": {
getLogger: getLoggerStub,
},
Expand Down
6 changes: 3 additions & 3 deletions test/lib/build/helpers/createBuildManifest.integration.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from "ava";
import path from "node:path";
import createBuildManifest from "../../../../lib/build/helpers/createBuildManifest.js";
import Module from "../../../../lib/graph/Module.js";
import Specification from "../../../../lib/specifications/Specification.js";
import createBuildManifest from "../../../../src/build/helpers/createBuildManifest.js";
import Module from "../../../../src/graph/Module.js";
import Specification from "../../../../src/specifications/Specification.js";

const __dirname = import.meta.dirname;

Expand Down
4 changes: 2 additions & 2 deletions test/lib/build/helpers/createBuildManifest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from "ava";
import path from "node:path";
import semver from "semver";
import createBuildManifest from "../../../../lib/build/helpers/createBuildManifest.js";
import Specification from "../../../../lib/specifications/Specification.js";
import createBuildManifest from "../../../../src/build/helpers/createBuildManifest.js";
import Specification from "../../../../src/specifications/Specification.js";

const __dirname = import.meta.dirname;

Expand Down
2 changes: 1 addition & 1 deletion test/lib/config/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test.beforeEach(async (t) => {
t.context.promisifyStub = sinon.stub();
t.context.resolveStub = sinon.stub().callsFake((path) => path);
t.context.joinStub = sinon.stub().callsFake((...args) => args.join("/"));
t.context.Configuration = await esmock.p("../../../lib/config/Configuration.js", {
t.context.Configuration = await esmock.p("../../../src/config/Configuration.js", {
"node:path": {
resolve: t.context.resolveStub,
join: t.context.joinStub,
Expand Down
2 changes: 1 addition & 1 deletion test/lib/graph/Module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from "ava";
import sinon from "sinon";
import path from "node:path";
import Module from "../../../lib/graph/Module.js";
import Module from "../../../src/graph/Module.js";

const __dirname = import.meta.dirname;

Expand Down
4 changes: 2 additions & 2 deletions test/lib/graph/ProjectGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from "node:path";
import test from "ava";
import sinonGlobal from "sinon";
import esmock from "esmock";
import Specification from "../../../lib/specifications/Specification.js";
import Specification from "../../../src/specifications/Specification.js";

const __dirname = import.meta.dirname;

Expand Down Expand Up @@ -74,7 +74,7 @@ test.beforeEach(async (t) => {
isLevelEnabled: () => true,
};

t.context.ProjectGraph = await esmock.p("../../../lib/graph/ProjectGraph.js", {
t.context.ProjectGraph = await esmock.p("../../../src/graph/ProjectGraph.js", {
"@ui5/logger": {
getLogger: sinon.stub().withArgs("graph:ProjectGraph").returns(t.context.log),
},
Expand Down
2 changes: 1 addition & 1 deletion test/lib/graph/ShimCollection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from "ava";
import ShimCollection from "../../../lib/graph/ShimCollection.js";
import ShimCollection from "../../../src/graph/ShimCollection.js";

test("Add shims", (t) => {
const collection = new ShimCollection();
Expand Down
4 changes: 2 additions & 2 deletions test/lib/graph/Workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from "node:path";
import test from "ava";
import sinonGlobal from "sinon";
import esmock from "esmock";
import Module from "../../../lib/graph/Module.js";
import Module from "../../../src/graph/Module.js";

const __dirname = import.meta.dirname;
const libraryD = path.join(__dirname, "..", "..", "fixtures", "library.d");
Expand Down Expand Up @@ -35,7 +35,7 @@ test.beforeEach(async (t) => {
isLevelEnabled: () => true,
};

t.context.Workspace = await esmock("../../../lib/graph/Workspace.js", {
t.context.Workspace = await esmock("../../../src/graph/Workspace.js", {
"@ui5/logger": {
getLogger: sinon.stub().withArgs("graph:Workspace").returns(t.context.log),
},
Expand Down
12 changes: 6 additions & 6 deletions test/lib/graph/graph.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import test from "ava";
import path from "node:path";
import sinonGlobal from "sinon";
import esmock from "esmock";
import Workspace from "../../../lib/graph/Workspace.js";
import CacheMode from "../../../lib/ui5Framework/maven/CacheMode.js";
import Workspace from "../../../src/graph/Workspace.js";
import CacheMode from "../../../src/ui5Framework/maven/CacheMode.js";
const __dirname = import.meta.dirname;

const fixturesPath = path.join(__dirname, "..", "..", "fixtures");
Expand All @@ -23,10 +23,10 @@ test.beforeEach(async (t) => {

t.context.projectGraphBuilderStub = sinon.stub().resolves("graph");
t.context.enrichProjectGraphStub = sinon.stub();
t.context.graph = await esmock.p("../../../lib/graph/graph.js", {
"../../../lib/graph/providers/NodePackageDependencies.js": t.context.MockNpmProvider,
"../../../lib/graph/projectGraphBuilder.js": t.context.projectGraphBuilderStub,
"../../../lib/graph/helpers/ui5Framework.js": {
t.context.graph = await esmock.p("../../../src/graph/graph.js", {
"../../../src/graph/providers/NodePackageDependencies.js": t.context.MockNpmProvider,
"../../../src/graph/projectGraphBuilder.js": t.context.projectGraphBuilderStub,
"../../../src/graph/helpers/ui5Framework.js": {
enrichProjectGraph: t.context.enrichProjectGraphStub,
},
});
Expand Down
14 changes: 7 additions & 7 deletions test/lib/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from "ava";
import path from "node:path";
import sinonGlobal from "sinon";
import esmock from "esmock";
import CacheMode from "../../../lib/ui5Framework/maven/CacheMode.js";
import CacheMode from "../../../src/ui5Framework/maven/CacheMode.js";

const __dirname = import.meta.dirname;
const fixturesPath = path.join(__dirname, "..", "..", "fixtures");
Expand Down Expand Up @@ -30,12 +30,12 @@ test.beforeEach(async (t) => {

t.context.projectGraphBuilderStub = sinon.stub().resolves("graph");
t.context.enrichProjectGraphStub = sinon.stub();
t.context.graph = await esmock.p("../../../lib/graph/graph.js", {
"../../../lib/graph/providers/NodePackageDependencies.js": t.context.MockNpmProvider,
"../../../lib/graph/providers/DependencyTree.js": t.context.DummyDependencyTreeProvider,
"../../../lib/graph/helpers/createWorkspace.js": t.context.createWorkspaceStub,
"../../../lib/graph/projectGraphBuilder.js": t.context.projectGraphBuilderStub,
"../../../lib/graph/helpers/ui5Framework.js": {
t.context.graph = await esmock.p("../../../src/graph/graph.js", {
"../../../src/graph/providers/NodePackageDependencies.js": t.context.MockNpmProvider,
"../../../src/graph/providers/DependencyTree.js": t.context.DummyDependencyTreeProvider,
"../../../src/graph/helpers/createWorkspace.js": t.context.createWorkspaceStub,
"../../../src/graph/projectGraphBuilder.js": t.context.projectGraphBuilderStub,
"../../../src/graph/helpers/ui5Framework.js": {
enrichProjectGraph: t.context.enrichProjectGraphStub,
},
});
Expand Down
6 changes: 3 additions & 3 deletions test/lib/graph/graphFromObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from "ava";
import path from "node:path";
import sinonGlobal from "sinon";
import esmock from "esmock";
import ValidationError from "../../../lib/validation/ValidationError.js";
import ValidationError from "../../../src/validation/ValidationError.js";

const __dirname = import.meta.dirname;

Expand Down Expand Up @@ -31,8 +31,8 @@ test.beforeEach(async (t) => {
isLevelEnabled: () => true,
};

t.context.graph = await esmock.p("../../../lib/graph/graph.js", {
"../../../lib/graph/projectGraphBuilder": await esmock("../../../lib/graph/projectGraphBuilder.js", {
t.context.graph = await esmock.p("../../../src/graph/graph.js", {
"../../../src/graph/projectGraphBuilder": await esmock("../../../src/graph/projectGraphBuilder.js", {
"@ui5/logger": {
getLogger: sinon.stub().withArgs("graph:projectGraphBuilder").returns(t.context.log),
},
Expand Down
2 changes: 1 addition & 1 deletion test/lib/graph/graphFromPackageDependencies.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from "ava";
import path from "node:path";
import sinonGlobal from "sinon";
import {graphFromPackageDependencies} from "../../../lib/graph/graph.js";
import {graphFromPackageDependencies} from "../../../src/graph/graph.js";

const __dirname = import.meta.dirname;

Expand Down
2 changes: 1 addition & 1 deletion test/lib/graph/graphFromStaticFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from "ava";
import path from "node:path";
import sinonGlobal from "sinon";

import {graphFromStaticFile} from "../../../lib/graph/graph.js";
import {graphFromStaticFile} from "../../../src/graph/graph.js";

const __dirname = import.meta.dirname;

Expand Down
Loading

0 comments on commit 9dc300e

Please sign in to comment.