Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Commit

Permalink
refactor(shared): configuration param for parser provider (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascariandrea authored Sep 22, 2022
1 parent af1fcec commit 6688017
Show file tree
Hide file tree
Showing 22 changed files with 282 additions and 144 deletions.
20 changes: 14 additions & 6 deletions packages/shared/src/providers/__tests__/parser.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const Contribution = t.type(
'Contribution'
);

type Contribution = t.TypeOf<typeof Contribution>;

const { savingTime, ...ContributionTypeProps } = Contribution.props;

const ContributionArb = getArbitrary(t.type({ ...ContributionTypeProps })).map(
Expand All @@ -55,6 +57,8 @@ const Metadata = t.type({
savingTime: date,
});

type Metadata = t.TypeOf<typeof Metadata>;

const { savingTime: _savingTime, ...metadataProps } = Metadata.props;
const MetadataArb = getArbitrary(t.type({ ...metadataProps })).map((c) => {
return {
Expand All @@ -64,11 +68,7 @@ const MetadataArb = getArbitrary(t.type({ ...metadataProps })).map((c) => {
});

describe('Parser Provider', () => {
const providerCtx: ParserProviderContext<
typeof Contribution,
typeof Metadata,
any
> = {
const providerCtx: ParserProviderContext<Contribution, Metadata, any, any> = {
db: db as any,
parsers: {
home: homeParser,
Expand All @@ -87,6 +87,9 @@ describe('Parser Provider', () => {
},
buildMetadata,
saveResults: saveResults,
config: {
downloads: '/download/here',
},
};

afterEach(() => {
Expand All @@ -108,6 +111,7 @@ describe('Parser Provider', () => {
const output = payloadToTableOutput<
typeof Contribution,
typeof Metadata,
any,
{ [key: string]: any }
>(
(s) => s.id,
Expand Down Expand Up @@ -214,7 +218,11 @@ describe('Parser Provider', () => {
backInTime: 0,
});

expect(homeParser).toHaveBeenCalledWith(sources[0], {});
expect(homeParser).toHaveBeenCalledWith(
sources[0],
{},
{ downloads: '/download/here' }
);

expect(saveResults).toHaveBeenCalledWith(sources[0], metadata);

Expand Down
Loading

0 comments on commit 6688017

Please sign in to comment.