<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import { readFileSync } from 'fs';
|
|
import { join } from 'path';
|
|
import { processProjectReports } from './get-gradle-report';
|
|
|
|
describe('processProjectReports', () => {
|
|
it('should process project reports', () => {
|
|
const projectReportLines = readFileSync(
|
|
join(__dirname, '__mocks__/gradle-project-report.txt'),
|
|
'utf-8'
|
|
).split('\n');
|
|
const report = processProjectReports(projectReportLines);
|
|
expect(
|
|
Object.keys(Object.fromEntries(report.gradleProjectToTasksTypeMap))
|
|
).toEqual(['', ':app', ':list', ':utilities']);
|
|
});
|
|
|
|
it('should process project reports with println', () => {
|
|
const projectReportLines = readFileSync(
|
|
join(__dirname, '__mocks__/gradle-project-report-println.txt'),
|
|
'utf-8'
|
|
).split('\n');
|
|
const report = processProjectReports(projectReportLines);
|
|
expect(
|
|
Object.keys(Object.fromEntries(report.gradleProjectToTasksTypeMap))
|
|
).toEqual(['', ':app', ':list', ':utilities']);
|
|
});
|
|
|
|
it('should process properties report with child projects', () => {
|
|
const report = processProjectReports([
|
|
'> Task :propertyReport',
|
|
`See the report at: file://${__dirname}/__mocks__/gradle-properties-report-child-projects.txt`,
|
|
]);
|
|
expect(report.gradleProjectToProjectName.get('')).toEqual('My Application');
|
|
expect(report.gradleProjectToChildProjects.get('')).toEqual([
|
|
'app',
|
|
'mylibrary',
|
|
]);
|
|
});
|
|
|
|
it('should process properties report for projects without child projects', () => {
|
|
const report = processProjectReports([
|
|
'> Task :propertyReport',
|
|
`See the report at: file://${__dirname}/__mocks__/gradle-properties-report-no-child-projects.txt`,
|
|
]);
|
|
expect(report.gradleProjectToProjectName.get('')).toEqual('app');
|
|
expect(report.gradleProjectToChildProjects.get('')).toEqual([]);
|
|
});
|
|
});
|