Skip to content

Commit

Permalink
test: improve coverage with flattenOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyHuss committed Aug 3, 2023
1 parent abb4e78 commit e516e05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/datasource-replica/src/options/flattener/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type ResolvedFlattenOptions = ResolvedOptions['flattenOptions'];
type ModelFlattenOptions = ResolvedFlattenOptions[string];

function listFields(field: Field, depth: number): string[] {
console.log('enter list fields');

Check failure on line 15 in packages/datasource-replica/src/options/flattener/options.ts

View workflow job for this annotation

GitHub Actions / Linting & Testing (datasource-replica)

Unexpected console statement
if (depth === 0) return [];
if (Array.isArray(field)) return listFields(field[0], depth);
if (isLeafField(field)) return [''];
Expand Down Expand Up @@ -80,6 +81,7 @@ async function getManualFlattenOptions(

if (!field) throw new Error(`Collection ${collectionName} not found in schema`);

// console.log('manual flatten');
const asModels = [...(collectionOptions.asModels ?? [])].sort();

const asFields = (collectionOptions.asFields ?? [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe('flattener', () => {
],
flattenMode: 'manual',
flattenOptions: {
books: { asModels: ['authors'] },
books: { asModels: ['authors'], asFields: ['id'] },
},
});

Expand Down

0 comments on commit e516e05

Please sign in to comment.