Skip to content

Commit

Permalink
fix: update vector-annotation test
Browse files Browse the repository at this point in the history
  • Loading branch information
mjfwebb committed Jul 2, 2024
1 parent 1147fb3 commit f3eb7e6
Showing 1 changed file with 42 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,59 @@
* limitations under the License.
*/

import { makeDirectiveNode } from "@graphql-tools/utils";
import type { DirectiveNode } from "graphql";
import { vectorDirective } from "../../../graphql/directives";
import { Kind, type DirectiveNode } from "graphql";
import { parseVectorAnnotation } from "./vector-annotation";

describe("parseVectorAnnotation", () => {
it("should parse correctly", () => {
const directive: DirectiveNode = makeDirectiveNode(
"vector",
{ indexes: [{ indexName: "ProductName", propertyName: "name", provider: "OpenAI" }] },
vectorDirective
);
const directive: DirectiveNode = {
kind: Kind.DIRECTIVE,
name: { kind: Kind.NAME, value: "vector" },
arguments: [
{
kind: Kind.ARGUMENT,
name: { kind: Kind.NAME, value: "indexes" },
value: {
kind: Kind.LIST,
values: [
{
kind: Kind.OBJECT,
fields: [
{
kind: Kind.OBJECT_FIELD,
name: { kind: Kind.NAME, value: "indexName" },
value: { kind: Kind.STRING, value: "ProductName" },
},
{
kind: Kind.OBJECT_FIELD,
name: { kind: Kind.NAME, value: "propertyName" },
value: { kind: Kind.STRING, value: "name" },
},
{
kind: Kind.OBJECT_FIELD,
name: { kind: Kind.NAME, value: "queryName" },
value: { kind: Kind.STRING, value: "myQueryName" },
},
{
kind: Kind.OBJECT_FIELD,
name: { kind: Kind.NAME, value: "provider" },
value: { kind: Kind.ENUM, value: "OpenAI" },
},
],
},
],
},
},
],
};
const vectorAnnotation = parseVectorAnnotation(directive);
expect(vectorAnnotation).toEqual({
name: "vector",
indexes: [
{
indexName: "ProductName",
propertyName: "name",
queryName: "myQueryName",
provider: "OpenAI",
},
],
Expand Down

0 comments on commit f3eb7e6

Please sign in to comment.