Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-chambers committed Nov 22, 2023
1 parent 0845f7a commit 9b7b645
Showing 1 changed file with 53 additions and 18 deletions.
71 changes: 53 additions & 18 deletions test/schema-ndc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ describe("by_keys function", () => {

const schema = expectOk(createSchema([tableSchema], {}));

const expectedFunctionDef: FunctionDefinition = {
type: "by_keys",
tableSchema: tableSchema,
functionInfo: artistsFunctionInfo,
}

const expectedObjectTypes: ObjectTypes = {
Artists_pk: {
description: "Values of the primary key for the 'Artists' table",
Expand All @@ -90,6 +84,21 @@ describe("by_keys function", () => {
}
}

const expectedFunctionDef: FunctionDefinition = {
type: "by_keys",
tableSchema: tableSchema,
functionInfo: artistsFunctionInfo,
primaryKeySchema: {
hashKeySchema: {
attributeName: "ArtistName",
dynamoType: "S",
schemaType: { type: "named", name: "String" }
},
rangeKeySchema: null
},
tableRowType: expectedObjectTypes["Artists_row"]!,
}

expect(schema.functions).toHaveProperty("Artists_by_keys");
expect(schema.functions["Artists_by_keys"]).toEqual(expectedFunctionDef);
expect(schema.schemaResponse.object_types).toEqual(expectedObjectTypes);
Expand Down Expand Up @@ -122,12 +131,6 @@ describe("by_keys function", () => {

const schema = expectOk(createSchema([tableSchema], {}));

const expectedFunctionDef: FunctionDefinition = {
type: "by_keys",
tableSchema: tableSchema,
functionInfo: artistsFunctionInfo,
};

const expectedObjectTypes: ObjectTypes = {
Artists_pk: {
description: "Values of the primary key for the 'Artists' table",
Expand Down Expand Up @@ -157,6 +160,25 @@ describe("by_keys function", () => {
}
}

const expectedFunctionDef: FunctionDefinition = {
type: "by_keys",
tableSchema: tableSchema,
functionInfo: artistsFunctionInfo,
primaryKeySchema: {
hashKeySchema: {
attributeName: "ArtistName",
dynamoType: "S",
schemaType: { type: "named", name: "String" }
},
rangeKeySchema: {
attributeName: "AlbumTitle",
dynamoType: "S",
schemaType: { type: "named", name: "String" }
}
},
tableRowType: expectedObjectTypes["Artists_row"]!,
};

expect(schema.functions).toHaveProperty("Artists_by_keys");
expect(schema.functions["Artists_by_keys"]).toEqual(expectedFunctionDef);
expect(schema.schemaResponse.object_types).toEqual(expectedObjectTypes);
Expand Down Expand Up @@ -229,12 +251,6 @@ describe("by_keys function", () => {

const schema = expectOk(createSchema([tableSchema], customObjectTypes));

const expectedFunctionDef: FunctionDefinition = {
type: "by_keys",
tableSchema: tableSchema,
functionInfo: artistsFunctionInfo,
};

const expectedObjectTypes: ObjectTypes = {
...customObjectTypes,
Artists_pk: {
Expand Down Expand Up @@ -277,6 +293,25 @@ describe("by_keys function", () => {
}
}

const expectedFunctionDef: FunctionDefinition = {
type: "by_keys",
tableSchema: tableSchema,
functionInfo: artistsFunctionInfo,
primaryKeySchema: {
hashKeySchema: {
attributeName: "ArtistName",
dynamoType: "S",
schemaType: { type: "named", name: "String" }
},
rangeKeySchema: {
attributeName: "AlbumTitle",
dynamoType: "S",
schemaType: { type: "named", name: "String" }
}
},
tableRowType: expectedObjectTypes["Artists_row"]!,
};

expect(schema.functions).toHaveProperty("Artists_by_keys");
expect(schema.functions["Artists_by_keys"]).toEqual(expectedFunctionDef);
expect(schema.schemaResponse.object_types).toEqual(expectedObjectTypes);
Expand Down

0 comments on commit 9b7b645

Please sign in to comment.