Skip to content

Commit

Permalink
test: ✅ Passing :)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Dec 5, 2021
1 parent 8bec887 commit c876954
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 0 deletions.
Empty file added test/dfsAllPaths.1.approved.txt
Empty file.
17 changes: 17 additions & 0 deletions test/dfsAllPaths.2.approved.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
[
"f",
"e",
"d",
"c",
"b",
"a"
],
[
"f",
"e",
"d",
"c",
"a"
]
]
41 changes: 41 additions & 0 deletions test/dfsAllPaths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { MultiGraph } from "graphology";
import { dfsAllPaths } from "../src/graphUtils";
import { testGraph } from "./testUtils";

require("approvals").mocha();

function verify(sol: any) {
this.verifyAsJSON(sol, {
reporters: ["tortoisemerge"],
appendEOL: true,
normalizeLineEndingsTo: "\r\n",
});
}

describe("dfsAllPaths", function () {
it("1", function () {
const g = new MultiGraph();
g.addNode("A");
g.addNode("B");

g.addEdge("A", "B", { dir: "up", field: "up" });

const paths = dfsAllPaths(g, "A");

verify.call(this, paths);
// this.verifyAsJSON(paths, {
// reporters: ["tortoisemerge"],
// appendEOL: true,
// normalizeLineEndingsTo: "\r\n",
// });
});

it("2", function () {
const g = testGraph();
const paths = dfsAllPaths(g, "a");

verify.call(this, paths);
});
});

export {};
28 changes: 28 additions & 0 deletions test/getReflexiveClosure.1.approved.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"allowSelfLoops": true,
"attributes": {},
"directedSelfLoopCount": 0,
"directedSize": 2,
"edges": {
"0. (A)->(B)": {
"dir": "up",
"field": "up"
},
"0. (B)->(A)": {
"dir": "down",
"field": "down"
}
},
"implementation": "graphology",
"multi": true,
"nodes": {
"A": {},
"B": {}
},
"order": 2,
"selfLoopCount": 0,
"size": 2,
"type": "mixed",
"undirectedSelfLoopCount": 0,
"undirectedSize": 0
}
25 changes: 25 additions & 0 deletions test/getReflexiveClosure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { MultiGraph } from "graphology";
import { getReflexiveClosure } from "../src/graphUtils";
import { testHiers, verify } from "./testUtils";

require("approvals").mocha();

describe("getReflexiveClosure", function () {
it("1", async function () {
const userHiers = testHiers();

const g = new MultiGraph();
g.addNode("A");
g.addNode("B");

g.addEdge("A", "B", { dir: "up", field: "up" });

const closed = getReflexiveClosure(g, userHiers);

const gStr = closed.inspect();

verify.call(this, gStr);
});
});

export {};

0 comments on commit c876954

Please sign in to comment.