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

Split type check tests into separate files #196

Merged
merged 1 commit into from
Sep 7, 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
106 changes: 106 additions & 0 deletions packages/viz/test/types/graph-objects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { instance } from "@viz-js/viz";

instance().then(viz => {
viz.render({});

viz.render({
edges: [
{ tail: "a", head: "b" }
]
});

viz.render({
directed: false,
strict: false,
name: "G",
graphAttributes: {
label: "Test"
},
edgeAttributes: {
color: "green"
},
nodeAttributes: {
shape: "circle"
},
nodes: [
{ name: "a", attributes: { label: "A" } }
],
edges: [
{ tail: "a", head: "b", attributes: { label: "test" } }
],
subgraphs: [
{
name: "cluster1",
graphAttributes: {
color: "green"
},
edgeAttributes: {
color: "blue"
},
nodeAttributes: {
color: "red"
},
subgraphs: [
{
nodes: [
{ name: "b" }
]
}
]
}
]
});

viz.render({
graphAttributes: {
width: 2,
abc: true,
label: { html: "<b>test</b>" }
},
nodes: [
{
name: "a",
attributes: {
width: 2,
abc: true,
label: { html: "<b>test</b>" }
}
}
]
});

viz.render({
graphAttributes: {
// @ts-expect-error
blah: null
}
});

viz.render({
graphAttributes: {
// @ts-expect-error
label: { stuff: "abc" }
}
});

viz.render({
subgraphs: [
{
// @ts-expect-error
directed: false
}
]
});

viz.render({
subgraphs: [
{
// @ts-expect-error
strict: true
}
]
});

// @ts-expect-error
viz.render({ a: "b" });
});
171 changes: 0 additions & 171 deletions packages/viz/test/types/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/viz/test/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"typescript": "^5.1.3"
},
"scripts": {
"check-types": "tsc --strict --lib es2015,dom --noEmit index.ts"
"check-types": "tsc --strict --lib es2015,dom --noEmit *.ts"
}
}
47 changes: 47 additions & 0 deletions packages/viz/test/types/render-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { type RenderOptions } from "@viz-js/viz";

let options: RenderOptions = {};

options.format = "svg";

options.engine = "dot";

options.yInvert = true;

options.reduce = true;

options.graphAttributes = {
rankdir: "LR",
width: 2,
label: { html: "<b>test</b>" },
test: true
};

options.nodeAttributes = {
rankdir: "LR",
width: 2,
label: { html: "<b>test</b>" },
test: true
};

options.edgeAttributes = {
rankdir: "LR",
width: 2,
label: { html: "<b>test</b>" },
test: true
};

// @ts-expect-error
options.format = false;

// @ts-expect-error
options.engine = 123;

// @ts-expect-error
options.yInvert = 1;

// @ts-expect-error
options.whatever = 123;

// @ts-expect-error
options.graphAttributes = { something: { whatever: 123 } };
45 changes: 45 additions & 0 deletions packages/viz/test/types/render-result.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { instance, type RenderResult, type RenderError } from "@viz-js/viz";

instance().then(viz => {
let result: RenderResult = viz.render("digraph { a -> b }");

switch (result.status) {
case "success":
{
let output: string = result.output;
break;
}

case "failure":
{
// @ts-expect-error
let output: string = result.output;
break;
}

// @ts-expect-error
case "invalid":
break;
}

let error: RenderError | undefined = result.errors[0];

if (typeof error !== "undefined") {
let message: string = error.message;

switch (error.level) {
case "error":
break;

case "warning":
break;

case undefined:
break;

// @ts-expect-error
case "invalid":
break;
}
}
});
Loading