Skip to content

Commit

Permalink
Roll out digest language in another composite fetcher #3239
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiosironi committed May 15, 2024
1 parent 00e8004 commit 79534ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { pipe } from 'fp-ts/function';
import { fetchAccessMicrobiologyEvaluationDigest } from './access-microbiology';
import { fetchDoiEvaluationDigestByPublisher } from './fetch-doi-evaluation-digest-by-publisher';
import { fetchEvaluationFromAppropriateService } from './fetch-evaluation-from-appropriate-service';
import { fetchEvaluationDigestFromAppropriateService } from './fetch-evaluation-digest-from-appropriate-service';
import { fetchHypothesisAnnotation } from './hypothesis';
import { fetchNcrcEvaluationDigest } from './ncrc';
import { fetchPrelightsHighlight } from './prelights';
Expand All @@ -26,5 +26,5 @@ export const createFetchEvaluationDigest = (queryExternalService: QueryExternalS
prelights: fetchPrelightsHighlight(queryExternalService, logger),
rapidreviews: fetchRapidReviewsEvaluationDigest(queryExternalService, logger),
},
fetchEvaluationFromAppropriateService,
fetchEvaluationDigestFromAppropriateService,
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as DE from '../../types/data-error';
import * as EL from '../../types/evaluation-locator';
import { ExternalQueries } from '../external-queries';

export const fetchEvaluationFromAppropriateService = (fetchers: Record<string, EvaluationDigestFetcher>): ExternalQueries['fetchEvaluationDigest'] => (id) => pipe(
export const fetchEvaluationDigestFromAppropriateService = (fetchers: Record<string, EvaluationDigestFetcher>): ExternalQueries['fetchEvaluationDigest'] => (id) => pipe(
fetchers,
R.lookup(EL.service(id)),
TE.fromOption(() => DE.notFound),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import * as E from 'fp-ts/Either';
import * as T from 'fp-ts/Task';
import * as TE from 'fp-ts/TaskEither';
import { flow, identity, pipe } from 'fp-ts/function';
import { fetchEvaluationFromAppropriateService } from '../../../src/third-parties/fetch-evaluation-digest/fetch-evaluation-from-appropriate-service';
import { fetchEvaluationDigestFromAppropriateService } from '../../../src/third-parties/fetch-evaluation-digest/fetch-evaluation-digest-from-appropriate-service';
import * as DE from '../../../src/types/data-error';
import * as RI from '../../../src/types/evaluation-locator';
import { arbitrarySanitisedHtmlFragment } from '../../helpers';
import { shouldNotBeCalled } from '../../should-not-be-called';
import { arbitraryEvaluationLocator } from '../../types/evaluation-locator.helper';

describe('fetch-evaluation-from-appropriate-service', () => {
describe('fetch-evaluation-digest-from-appropriate-service', () => {
describe('when the service is supported', () => {
it('returns the fetched evaluation', async () => {
it('returns the fetched evaluation digest', async () => {
const reviewId = arbitraryEvaluationLocator();
const digest = arbitrarySanitisedHtmlFragment();
const fetchers = {
[RI.service(reviewId)]: () => TE.right(digest),
};

const result = await fetchEvaluationFromAppropriateService(fetchers)(reviewId)();
const result = await fetchEvaluationDigestFromAppropriateService(fetchers)(reviewId)();

expect(result).toStrictEqual(E.right(digest));
});
Expand All @@ -31,7 +31,7 @@ describe('fetch-evaluation-from-appropriate-service', () => {
const id = arbitraryEvaluationLocator();
const result = await pipe(
id,
fetchEvaluationFromAppropriateService(fetchers),
fetchEvaluationDigestFromAppropriateService(fetchers),
T.map(flow(
E.matchW(
identity,
Expand Down

0 comments on commit 79534ba

Please sign in to comment.