Skip to content

Commit

Permalink
Add test for custom task attached to a disabled standard task
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Sep 27, 2023
1 parent 4053bdd commit 616f420
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/lib/build/TaskRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,45 @@ test("Custom task: requiredDependenciesCallback returns Array instead of Set", a
}, "Threw with expected error message");
});

test("Custom task attached to a disabled task", async (t) => {
const {graph, taskUtil, taskRepository, TaskRunner, projectBuildLogger, sinon, customTask} = t.context;

const project = getMockProject("application");
const customTaskFnStub = sinon.stub();
project.getBundles = emptyarray;
project.getCustomTasks = () => [
{name: "myTask", afterTask: "generateBundle", configuration: "dog"}
];

taskRepository.getTask = sinon.stub().returns({task: sinon.stub()});
customTask.getTask = () => customTaskFnStub;

const taskRunner = new TaskRunner({
project, graph, taskUtil, taskRepository, log: projectBuildLogger, buildConfig
});

await taskRunner.runTasks();

const setTasksArgs = projectBuildLogger.setTasks.firstCall.args[0];
t.true(setTasksArgs.includes("myTask"), "Custom task 'myTask' is queried");
t.is(customTaskFnStub.calledOnce, true, "Custom task 'myTask' is executed");
t.false(setTasksArgs.includes("generateBundle"),
"generateBundle standard task is excluded from the execution list");

t.deepEqual(
setTasksArgs,
[
"escapeNonAsciiCharacters",
"replaceCopyright",
"replaceVersion",
"minify",
"generateFlexChangesBundle",
"generateComponentPreload",
"myTask",
],
"Correct tasks execution");
});

test.serial("_addTask", async (t) => {
const {sinon, graph, taskUtil, taskRepository, TaskRunner, projectBuildLogger} = t.context;

Expand Down

0 comments on commit 616f420

Please sign in to comment.