blog infra
This commit is contained in:
@@ -110,12 +110,14 @@ export class BCMRHttp extends BaseBCMR {
|
||||
);
|
||||
|
||||
// Validate the payload body.
|
||||
try{
|
||||
try {
|
||||
const metadata = MetadataRegistrySchema.parse(await response.json());
|
||||
|
||||
return metadata;
|
||||
} catch(error: unknown) {
|
||||
throw new Error(`Unable to parse the metadata registry format. Detailed error: ${error}`);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(
|
||||
`Unable to parse the metadata registry format. Detailed error: ${error}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,10 +83,15 @@ export function findAllKeyOcurrences(
|
||||
|
||||
const keyValues: Array<unknown> = [];
|
||||
|
||||
function traverse(currentObj: Record<string | number | symbol, unknown>, depth: number = 0) {
|
||||
function traverse(
|
||||
currentObj: Record<string | number | symbol, unknown>,
|
||||
depth: number = 0,
|
||||
) {
|
||||
// Stop if depth exceeds the amount of 'allowedNestedLevels'.
|
||||
if (depth > allowedNestedLevels)
|
||||
throw new Error(`Maximum nesting level of ${allowedNestedLevels} reached.`);
|
||||
throw new Error(
|
||||
`Maximum nesting level of ${allowedNestedLevels} reached.`,
|
||||
);
|
||||
|
||||
// Stop when find a non object value.
|
||||
if (typeof currentObj !== 'object' || currentObj === null) return;
|
||||
|
||||
@@ -41,6 +41,8 @@ describe('BCMRComposite', () => {
|
||||
test('should fail if cantegoryId is not a registered entry', async () => {
|
||||
const invalidCategoryId = 'asd123';
|
||||
|
||||
await expect(bcmrComposite.getTokenData(invalidCategoryId)).rejects.toThrow();
|
||||
await expect(
|
||||
bcmrComposite.getTokenData(invalidCategoryId),
|
||||
).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user