Skip to content

Commit 5de3ffe

Browse files
committed
test: improve covers
1 parent e098cd0 commit 5de3ffe

File tree

6 files changed

+213
-1
lines changed

6 files changed

+213
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@
7474
"request": "^2.88.0",
7575
"slug": "^4.0.2",
7676
"striptags": "^3.1.1",
77-
"ts-node": "^9.1.1",
7877
"ts-jest": "^26.4.4",
78+
"ts-node": "^9.1.1",
7979
"word-wrap": "^1.2.1"
8080
},
8181
"graphdoc": {

plugins/navigation.object.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import projectPackage from "../test/empty.package.json";
2+
import NavigationObject from "./navigation.object";
3+
import schema from "../test/empty.schema.json";
4+
5+
describe("pĺugins/navigation.directive#NavigationDirectives", () => {
6+
test("plugin return empty", () => {
7+
const plugin = new NavigationObject(
8+
{
9+
...schema.data.__schema,
10+
types: [],
11+
},
12+
projectPackage,
13+
{}
14+
);
15+
16+
expect(plugin.getNavigations("Query")).toEqual([])
17+
})
18+
19+
test("plugin return navigation", () => {
20+
const plugin = new NavigationObject(schema.data.__schema, projectPackage, {});
21+
expect(plugin.getNavigations("Query")).toEqual([
22+
{
23+
title: "Objects",
24+
items: [
25+
{
26+
"href": "/directive.spec.html",
27+
"isActive": false,
28+
"text": "__Directive",
29+
},
30+
{
31+
"href": "/enumvalue.spec.html",
32+
"isActive": false,
33+
"text": "__EnumValue",
34+
},
35+
{
36+
"href": "/field.spec.html",
37+
"isActive": false,
38+
"text": "__Field",
39+
},
40+
{
41+
"href": "/inputvalue.spec.html",
42+
"isActive": false,
43+
"text": "__InputValue",
44+
},
45+
{
46+
"href": "/schema.spec.html",
47+
"isActive": false,
48+
"text": "__Schema",
49+
},
50+
{
51+
"href": "/type.spec.html",
52+
"isActive": false,
53+
"text": "__Type",
54+
},
55+
]
56+
}
57+
]);
58+
});
59+
});

plugins/navigation.scalar.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import projectPackage from "../test/empty.package.json";
2+
import NavigationScalar from "./navigation.object";
3+
import schema from "../test/empty.schema.json";
4+
5+
describe("pĺugins/navigation.directive#NavigationDirectives", () => {
6+
test("plugin return empty", () => {
7+
const plugin = new NavigationScalar(
8+
{
9+
...schema.data.__schema,
10+
types: [],
11+
},
12+
projectPackage,
13+
{}
14+
);
15+
16+
expect(plugin.getNavigations("Query")).toEqual([])
17+
})
18+
19+
test("plugin return navigation", () => {
20+
const plugin = new NavigationScalar(schema.data.__schema, projectPackage, {});
21+
expect(plugin.getNavigations("Query")).toEqual([
22+
{
23+
title: "Objects",
24+
items: [
25+
{
26+
"href": "/directive.spec.html",
27+
"isActive": false,
28+
"text": "__Directive",
29+
},
30+
{
31+
"href": "/enumvalue.spec.html",
32+
"isActive": false,
33+
"text": "__EnumValue",
34+
},
35+
{
36+
"href": "/field.spec.html",
37+
"isActive": false,
38+
"text": "__Field",
39+
},
40+
{
41+
"href": "/inputvalue.spec.html",
42+
"isActive": false,
43+
"text": "__InputValue",
44+
},
45+
{
46+
"href": "/schema.spec.html",
47+
"isActive": false,
48+
"text": "__Schema",
49+
},
50+
{
51+
"href": "/type.spec.html",
52+
"isActive": false,
53+
"text": "__Type",
54+
},
55+
]
56+
}
57+
]);
58+
});
59+
});

plugins/navigation.schema.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import projectPackage from "../test/empty.package.json";
2+
import NavigationSchema from "./navigation.schema";
3+
import schema from "../test/empty.schema.json";
4+
5+
describe("pĺugins/navigation.directive#NavigationDirectives", () => {
6+
test("plugin return empty", () => {
7+
const plugin = new NavigationSchema(
8+
{
9+
...schema.data.__schema,
10+
mutationType: null,
11+
queryType: null,
12+
subscriptionType: null
13+
},
14+
projectPackage,
15+
{}
16+
);
17+
18+
expect(plugin.getNavigations("Query")).toEqual([])
19+
})
20+
21+
test("plugin return navigation", () => {
22+
const plugin = new NavigationSchema(schema.data.__schema, projectPackage, {});
23+
expect(plugin.getNavigations("Query")).toEqual([
24+
{
25+
title: "Schema",
26+
items: [
27+
{
28+
"href": "/query.doc.html",
29+
"isActive": true,
30+
"text": "Query"
31+
}
32+
]
33+
}
34+
]);
35+
});
36+
});

plugins/navigation.schema.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ import { NavigationItem, NavigationSection, Plugin } from "../lib/utility";
44
export default class NavigationSchema extends Plugin
55
implements PluginInterface {
66
getNavigations(buildFrom?: string): NavigationSectionInterface[] {
7+
8+
if (
9+
!this.document.queryType &&
10+
!this.document.mutationType &&
11+
!this.document.subscriptionType
12+
) {
13+
return []
14+
}
15+
716
const section = new NavigationSection("Schema", []);
817

918
// Query

plugins/navigation.union.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import projectPackage from "../test/empty.package.json";
2+
import NavigationUnion from "./navigation.union";
3+
import schema from "../test/github.json";
4+
5+
describe("pĺugins/navigation.directive#NavigationDirectives", () => {
6+
test("plugin return empty", () => {
7+
const plugin = new NavigationUnion(
8+
{
9+
...schema.data.__schema,
10+
types: [],
11+
},
12+
projectPackage,
13+
{}
14+
);
15+
16+
expect(plugin.getNavigations("Query")).toEqual([])
17+
})
18+
19+
test("plugin return navigation", () => {
20+
const plugin = new NavigationUnion(schema.data.__schema, projectPackage, {});
21+
expect(plugin.getNavigations("Query")).toEqual([
22+
{
23+
title: "Unions",
24+
items: [
25+
{
26+
"href": "/issuetimelineitem.doc.html",
27+
"isActive": false,
28+
"text": "IssueTimelineItem",
29+
},
30+
{
31+
"href": "/projectcarditem.doc.html",
32+
"isActive": false,
33+
"text": "ProjectCardItem",
34+
},
35+
{
36+
"href": "/reviewdismissalallowanceactor.doc.html",
37+
"isActive": false,
38+
"text": "ReviewDismissalAllowanceActor",
39+
},
40+
{
41+
"href": "/searchresultitem.doc.html",
42+
"isActive": false,
43+
"text": "SearchResultItem",
44+
},
45+
]
46+
}
47+
]);
48+
});
49+
});

0 commit comments

Comments
 (0)