Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More tests #26

Merged
merged 21 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/old-tables-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/cypher-builder": patch
---

Fix typings for predicate functions
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
displayName: "@neo4j/cypher-builder",
setupFilesAfterEnv: ["jest-extended/all"],
roots: ["<rootDir>/src/", "<rootDir>/tests/"],
coverageDirectory: "<rootDir>/packages/cypher-builder/coverage/",
coverageDirectory: "<rootDir>/coverage/",
snapshotFormat: {
escapeString: true,
},
Expand Down
23 changes: 10 additions & 13 deletions src/Cypher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,21 @@ export { plus, minus, divide, multiply, mod, pow } from "./expressions/operation
// --Functions
export { CypherFunction as Function } from "./expressions/functions/CypherFunctions";

export { coalesce, randomUUID, id, elementId } from "./expressions/functions/CypherFunctions";

export { count, min, max, avg, sum, collect } from "./expressions/functions/AggregationFunctions";

export {
cypherDatetime as datetime,
cypherDate as date,
cypherLocalTime as localtime,
cypherLocalDatetime as localdatetime,
cypherTime as time,
} from "./expressions/functions/TemporalFunctions";

export * from "./expressions/functions/StringFunctions";
export * from "./expressions/functions/ListFunctions";
export * from "./expressions/functions/SpatialFunctions";
export * from "./expressions/functions/PathFunctions";
} from "./expressions/functions/temporal";
export * from "./expressions/functions/scalar";
export { count, min, max, avg, sum, collect } from "./expressions/functions/aggregation";
export * from "./expressions/functions/string";
export * from "./expressions/functions/list";
export * from "./expressions/functions/spatial";
export * from "./expressions/functions/path";

export { any, all, exists, single } from "./expressions/functions/PredicateFunctions";
export { any, all, exists, single } from "./expressions/functions/predicate";

// Procedures
export { CypherProcedure as Procedure, VoidCypherProcedure as VoidProcedure } from "./procedures/CypherProcedure";
Expand All @@ -116,10 +113,10 @@ export type { Expr, Predicate, Operation } from "./types";
export type { Yield } from "./procedures/Yield";
export type { ProjectionColumn } from "./clauses/sub-clauses/Projection";
export type { SetParam } from "./clauses/sub-clauses/Set";
export type { PredicateFunction } from "./expressions/functions/PredicateFunctions";
export type { PredicateFunction } from "./expressions/functions/predicate";
export type { Order } from "./clauses/sub-clauses/OrderBy";
export type { CompositeClause } from "./clauses/utils/concat";
export type { CypherAggregationFunction as AggregationFunction } from "./expressions/functions/AggregationFunctions";
export type { CypherAggregationFunction as AggregationFunction } from "./expressions/functions/aggregation";
export type { HasLabel } from "./expressions/HasLabel";

// utils
Expand Down
6 changes: 3 additions & 3 deletions src/apoc/cypher/run-first-column.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("apoc.cypher", () => {
expect(queryResult.params).toMatchInlineSnapshot(`{}`);
});

it("runFirstColumn with string", () => {
test("runFirstColumn with string", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const subquery = "MATCH (n:Film) RETURN n";

Expand All @@ -62,7 +62,7 @@ describe("apoc.cypher", () => {
expect(queryResult.params).toMatchInlineSnapshot(`{}`);
});

it("runFirstColumn with a map for parameters", () => {
test("runFirstColumn with a map for parameters", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const subquery = "MATCH (n) RETURN n";

Expand Down Expand Up @@ -119,7 +119,7 @@ describe("apoc.cypher", () => {
`);
});

it("runFirstColumn with an object for parameters", () => {
test("runFirstColumn with an object for parameters", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const subquery = "MATCH (n) RETURN n";

Expand Down
89 changes: 51 additions & 38 deletions src/clauses/Call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ describe("CypherBuilder Call", () => {
}"
`);
expect(queryResult.params).toMatchInlineSnapshot(`
{
"param0": "my-id",
}
`);
{
"param0": "my-id",
}
`);
});

test("Nested Call", () => {
Expand All @@ -65,13 +65,13 @@ describe("CypherBuilder Call", () => {
}"
`);
expect(queryResult.params).toMatchInlineSnapshot(`
{
"param0": "my-id",
}
`);
{
"param0": "my-id",
}
`);
});

it("CALL with inner with", () => {
test("CALL with inner with", () => {
const node = new Cypher.Node({ labels: ["Movie"] });

const matchClause = new Cypher.Match(node)
Expand All @@ -90,14 +90,27 @@ describe("CypherBuilder Call", () => {
`);

expect(queryResult.params).toMatchInlineSnapshot(`
{
"param0": "aa",
"param1": "bb",
}
`);
{
"param0": "aa",
"param1": "bb",
}
`);
});

it("CALL with external with", () => {
test("CALL with inner with fails if inner with is already set", () => {
const node = new Cypher.Node({ labels: ["Movie"] });

const matchClause = new Cypher.Match(node)
.where(Cypher.eq(new Cypher.Param("aa"), new Cypher.Param("bb")))
.return([node.property("title"), "movie"]);

const clause = new Cypher.Call(matchClause).innerWith(node);
expect(() => {
clause.innerWith(node);
}).toThrowError("Call import already set");
});

test("CALL with external with", () => {
const node = new Cypher.Node({ labels: ["Movie"] });

const matchClause = new Cypher.Match(node)
Expand All @@ -116,13 +129,13 @@ describe("CypherBuilder Call", () => {
`);

expect(queryResult.params).toMatchInlineSnapshot(`
{
"param0": "aa",
"param1": "bb",
}
`);
{
"param0": "aa",
"param1": "bb",
}
`);
});
it("CALL with external with clause", () => {
test("CALL with external with clause", () => {
const node = new Cypher.Node({ labels: ["Movie"] });

const matchClause = new Cypher.Match(node)
Expand All @@ -141,14 +154,14 @@ describe("CypherBuilder Call", () => {
`);

expect(queryResult.params).toMatchInlineSnapshot(`
{
"param0": "aa",
"param1": "bb",
}
`);
{
"param0": "aa",
"param1": "bb",
}
`);
});

it("CALL with unwind", () => {
test("CALL with unwind", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const movie = new Cypher.Variable();

Expand All @@ -169,14 +182,14 @@ describe("CypherBuilder Call", () => {
`);

expect(queryResult.params).toMatchInlineSnapshot(`
{
"param0": "aa",
"param1": "bb",
}
`);
{
"param0": "aa",
"param1": "bb",
}
`);
});

it("CALL with unwind passed as a clause", () => {
test("CALL with unwind passed as a clause", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const movie = new Cypher.Variable();

Expand All @@ -199,10 +212,10 @@ describe("CypherBuilder Call", () => {
`);

expect(queryResult.params).toMatchInlineSnapshot(`
{
"param0": "aa",
"param1": "bb",
}
`);
{
"param0": "aa",
"param1": "bb",
}
`);
});
});
Loading
Loading