added explicit any test

This commit is contained in:
Asier Isayas 2023-10-17 12:53:52 -04:00
parent 282004b09b
commit 6e267b2bba
3 changed files with 11 additions and 7 deletions

View File

@ -39,6 +39,7 @@ module.exports = {
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-explicit-any": "error",
"prefer-arrow/prefer-arrow-functions": ["error", { allowStandaloneDeclarations: true }],
eqeqeq: "error",
"react/display-name": "off",

View File

@ -117,6 +117,7 @@ describe("Query Utils", () => {
_attachments: "attachments/",
_ts: 1697136708,
};
it("should extract single partition key value", () => {
const singlePartitionKeyDefinition: PartitionKeyDefinition = {
kind: PartitionKeyKind.Hash,
@ -132,19 +133,18 @@ describe("Query Utils", () => {
});
it("should extract two partition key values", () => {
const singlePartitionKeyDefinition: PartitionKeyDefinition = {
const multiPartitionKeyDefinition: PartitionKeyDefinition = {
kind: PartitionKeyKind.MultiHash,
paths: ["/Type", "/Status"],
};
// const validPartitionKeyValues: Set<string> = new Set(["Stratovolcano", "Tephrochronology"]);
const validPartitionKeyValues: string[] = ["Stratovolcano", "Tephrochronology"];
const expectedPartitionKeyValues: string[] = ["Stratovolcano", "Tephrochronology"];
const partitionKeyValues: PartitionKey[] = extractPartitionKeyValues(
documentContent,
singlePartitionKeyDefinition,
multiPartitionKeyDefinition,
);
expect(partitionKeyValues.length).toBe(2);
expect(validPartitionKeyValues).toContain(documentContent["Type"]);
expect(validPartitionKeyValues).toContain(documentContent["Status"]);
expect(expectedPartitionKeyValues).toContain(documentContent["Type"]);
expect(expectedPartitionKeyValues).toContain(documentContent["Status"]);
});
it("should extract no partition key values", () => {

View File

@ -84,6 +84,7 @@ export const queryPagesUntilContentPresent = async (
return await doRequest(firstItemIndex);
};
/* eslint-disable @typescript-eslint/no-explicit-any */
export const extractPartitionKeyValues = (
documentContent: any,
partitionKeyDefinition: PartitionKeyDefinition,
@ -95,7 +96,9 @@ export const extractPartitionKeyValues = (
const partitionKeyValues: PartitionKey[] = [];
partitionKeyDefinition.paths.forEach((partitionKeyPath: string) => {
const partitionKeyPathWithoutSlash: string = partitionKeyPath.substring(1);
partitionKeyValues.push(documentContent[partitionKeyPathWithoutSlash]);
if (documentContent[partitionKeyPathWithoutSlash]) {
partitionKeyValues.push(documentContent[partitionKeyPathWithoutSlash]);
}
});
return partitionKeyValues;
};