Skip to content

Commit

Permalink
conform functional paths in dataFetcher to depend on props vs resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnC-80 committed Sep 20, 2023
1 parent f00d1aa commit a410e08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 7 additions & 6 deletions src/components/DataFetcher/DataFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ const logsUrl = createUrlFromArray('metadata-provider/jobExecutions', logsUrlPar
const compositeJobsUrl = createUrlFromArray('metadata-provider/jobExecutions', [...jobsUrlParams, 'subordinationTypeNotAny=COMPOSITE_CHILD']);
const compositeLogsUrl = createUrlFromArray('metadata-provider/jobExecutions', [...logsUrlParams, 'subordinationTypeNotAny=COMPOSITE_PARENT']);

export function getJobSplittingURL(resources, splittingURL, nonSplitting) {
if (!resources?.split_status.isPending) {
if (resources?.split_status?.records[0]?.splitStatus) {
export function getJobSplittingURL(props, splittingURL, nonSplitting) {
const { resources } = props;
if (!resources?.splitStatus.isPending) {
if (resources?.splitStatus?.records[0]?.splitStatus) {
return splittingURL;
} else if (resources?.split_status?.records[0]?.splitStatus === false) {
} else if (resources?.splitStatus?.records[0]?.splitStatus === false) {
return nonSplitting;
}
}
Expand All @@ -76,13 +77,13 @@ export class DataFetcher extends Component {
static manifest = Object.freeze({
jobs: {
type: 'okapi',
path: (_q, _p, resources) => getJobSplittingURL(resources, compositeJobsUrl, jobsUrl),
path: (_q, _p, _r, _l, props) => getJobSplittingURL(props, compositeJobsUrl, jobsUrl),
accumulate: true,
throwErrors: false,
},
logs: {
type: 'okapi',
path: (_q, _p, resources) => getJobSplittingURL(resources, compositeLogsUrl, logsUrl),
path: (_q, _p, _r, _l, props) => getJobSplittingURL(props, compositeLogsUrl, logsUrl),
accumulate: true,
throwErrors: false,
},
Expand Down
12 changes: 6 additions & 6 deletions src/components/DataFetcher/DataFetcher.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,19 @@ describe('DataFetcher component', () => {
});

describe('getJobSplittingURL', () => {
const trueResources = { split_status: { isPending: false, records: [{ splitStatus: true }] } };
const falseResources = { split_status: { isPending: false, records: [{ splitStatus: false }] } };
const pendingResources = { split_status: { isPending: true, records: [] } };
const trueResources = { splitStatus: { isPending: false, records: [{ splitStatus: true }] } };
const falseResources = { splitStatus: { isPending: false, records: [{ splitStatus: false }] } };
const pendingResources = { splitStatus: { isPending: true, records: [] } };
it('given a splitStatus of true, it provides the "trueUrl" parameter', () => {
expect(getJobSplittingURL(trueResources, 'trueUrl', 'falseUrl')).toBe('trueUrl');
expect(getJobSplittingURL({ resources: trueResources }, 'trueUrl', 'falseUrl')).toBe('trueUrl');
});

it('given a splitStatus of true, it provides the "falseUrl" parameter', () => {
expect(getJobSplittingURL(falseResources, 'trueUrl', 'falseUrl')).toBe('falseUrl');
expect(getJobSplittingURL({ resources: falseResources }, 'trueUrl', 'falseUrl')).toBe('falseUrl');
});

it('given a pending split status, it returns undefined', () => {
expect(getJobSplittingURL(pendingResources, 'trueUrl', 'falseUrl')).toBeUndefined();
expect(getJobSplittingURL({ resources: pendingResources }, 'trueUrl', 'falseUrl')).toBeUndefined();
});
});
});

0 comments on commit a410e08

Please sign in to comment.