Skip to content

Commit 073c5d5

Browse files
committed
feat: 🎸 Rendering improvements and fixes
1 parent b9998a3 commit 073c5d5

31 files changed

+233607
-145
lines changed

.yarn/releases/yarn-1.18.0.cjs

Lines changed: 147155 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
yarn-path ".yarn/releases/yarn-1.18.0.cjs"

jest.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ export const getJestConfig = (): Config.InitialOptions => ({
1616
coverageProvider: "v8",
1717
coverageReporters: [["lcov", { projectRoot: "../.." }], "clover", "json", "text"],
1818
collectCoverageFrom: ["./src/**/*.ts", "./src/**/*.tsx"],
19-
coveragePathIgnorePatterns: [".spec", "__tests__", "test", "tests", "types", "constants", "index.ts", "__snapshots__"],
19+
coveragePathIgnorePatterns: [
20+
".spec",
21+
"__tests__",
22+
"test",
23+
"tests",
24+
"types",
25+
"constants",
26+
"index.ts",
27+
"__snapshots__",
28+
],
2029
moduleDirectories: ["node_modules", "src"],
2130
transform: {
2231
"^.+\\.(j|t)sx?$": [

packages/core/jest.setup.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
// learn more: https://github.com/testing-library/jest-dom
55
import "@testing-library/jest-dom";
66
import "jest-extended";
7+
import { TextDecoder, TextEncoder } from "util";
78

89
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
910
// @ts-ignore
1011
global.IS_REACT_ACT_ENVIRONMENT = true;
12+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
13+
// @ts-ignore
14+
global.TextEncoder = TextEncoder;
15+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
16+
// @ts-ignore
17+
global.TextDecoder = TextDecoder;

packages/core/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Docusaurus plugin for documentation generation based on your .ts files",
66
"author": "Maciej Pyrc <[email protected]>",
77
"homepage": "",
8-
"license": "Apache 2.0",
8+
"license": "Apache-2.0",
99
"platform": "node",
1010
"main": "dist/index.js",
1111
"module": "dist/index.js",
@@ -24,23 +24,21 @@
2424
"tests": "yarn lint-staged",
2525
"release": "yarn semantic-release --extends ./release.config.cjs -t 'docsgen-v${version}'"
2626
},
27-
"peerDependencies": {
28-
"react": ">= 16.8.0",
29-
"react-dom": ">= 16.8.0"
30-
},
3127
"dependencies": {
3228
"@reins/query-params": "^0.1.1",
3329
"fs-extra": "^11.2.0",
30+
"js-beautify": "^1.15.1",
3431
"mdast-util-from-markdown": "^2.0.0",
3532
"mdast-util-mdx": "^3.0.0",
3633
"mdx-mermaid": "^2.0.0",
3734
"mermaid": ">=8.11.0",
3835
"micromark-extension-mdxjs": "2.0.0",
3936
"node-html-markdown": "^1.3.0",
4037
"node-html-parser": "^6.1.12",
41-
"pretty": "^2.0.0",
4238
"pretty-format": "^29.7.0",
4339
"prism-react-renderer": "^2.3.1",
40+
"react": ">= 16.8.0",
41+
"react-dom": ">= 16.8.0",
4442
"react-live": "^4.1.5",
4543
"react-simple-code-editor": "^0.13.1",
4644
"remark-admonitions": "^1.2.1",
@@ -54,6 +52,7 @@
5452
"@docusaurus/plugin-content-docs": ">= 2.0.0",
5553
"@docusaurus/types": ">= 2.0.0",
5654
"@types/fs-extra": "^11.0.4",
55+
"@types/js-beautify": "^1.14.3",
5756
"@types/pretty": "^2.0.3",
5857
"@types/react": "^18.0.21",
5958
"@types/react-dom": "^18.0.6",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { JSONOutput } from "typedoc";
3+
import { render } from "@testing-library/react";
4+
5+
import { HF_TREE_REFLECTION } from "../../snapshots/hf-core-reflection";
6+
import { ClassPage } from "pages/class.page";
7+
8+
describe("It should render correct type", () => {
9+
it("should render correct page element", () => {
10+
const RequestClass = HF_TREE_REFLECTION.children!.find(
11+
(reflection) => reflection.name === "Request",
12+
) as JSONOutput.DeclarationReflection;
13+
14+
const { container } = render(
15+
<ClassPage
16+
reflection={RequestClass}
17+
reflectionsTree={[HF_TREE_REFLECTION]}
18+
packageName="@hyper-fetch/core"
19+
packageOptions={{} as any}
20+
npmName="@hyper-fetch/core"
21+
pluginOptions={{} as any}
22+
/>,
23+
);
24+
25+
// Methods
26+
const setPayloadSection = container.querySelector(`[method-data="setPayloadMapper"]`);
27+
const setPayloadPreview = setPayloadSection?.querySelector(`[method-data="setPayloadMapper"] .api-docs__preview`);
28+
const setPayloadParams = setPayloadSection?.querySelector(".api-docs__parameters");
29+
30+
expect(setPayloadSection).toBeInTheDocument();
31+
expect(setPayloadSection?.innerHTML).toInclude("setPayloadMapper()");
32+
expect(setPayloadSection?.innerHTML).toInclude("Map data before it gets send to the server");
33+
34+
expect(setPayloadPreview).toBeInTheDocument();
35+
expect(setPayloadPreview?.innerHTML).toInclude("setPayloadMapper");
36+
expect(setPayloadPreview?.innerHTML).toInclude("MappedPayload");
37+
expect(setPayloadPreview?.innerHTML).toInclude("payloadMapper");
38+
expect(setPayloadParams).toBeInTheDocument();
39+
expect(setPayloadParams?.innerHTML).toInclude("Parameters");
40+
expect(setPayloadParams?.innerHTML).toInclude("payloadMapper");
41+
});
42+
});

packages/core/src/pages/components/__tests__/__snapshots__/type.spec.tsx.snap

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { JSONOutput } from "typedoc";
3+
import { render } from "@testing-library/react";
4+
5+
import { Parameters } from "../parameters";
6+
import { HF_TREE_REFLECTION } from "snapshots/hf-core-reflection";
7+
8+
describe("It should render correct parameters", () => {
9+
it("should render correct parameters", () => {
10+
const requestReflection = HF_TREE_REFLECTION.children!.find(
11+
(reflection) => reflection.name === "Request",
12+
) as JSONOutput.DeclarationReflection;
13+
14+
const { container } = render(
15+
<Parameters
16+
reflection={requestReflection}
17+
reflectionsTree={[HF_TREE_REFLECTION]}
18+
packageName="@hyper-fetch/core"
19+
packageOptions={{} as any}
20+
npmName="@hyper-fetch/core"
21+
pluginOptions={{} as any}
22+
/>,
23+
);
24+
25+
expect(container.innerHTML).toInclude("client");
26+
expect(container.innerHTML).toInclude("requestOptions");
27+
expect(container.innerHTML).toInclude("initialRequestConfiguration");
28+
});
29+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { JSONOutput } from "typedoc";
3+
import { render } from "@testing-library/react";
4+
5+
import { Returns } from "../returns";
6+
import { HF_TREE_REFLECTION } from "snapshots/hf-core-reflection";
7+
8+
describe("It should render correct returns", () => {
9+
it("should render correct returns", () => {
10+
const requestReflection = HF_TREE_REFLECTION.children!.find(
11+
(reflection) => reflection.name === "Request",
12+
) as JSONOutput.DeclarationReflection;
13+
const setPayloadMapperReflection = requestReflection.children!.find(
14+
(reflection) => reflection.name === "setPayloadMapper",
15+
) as JSONOutput.SomeReflection;
16+
17+
const { container } = render(
18+
<Returns
19+
reflection={setPayloadMapperReflection}
20+
reflectionsTree={[HF_TREE_REFLECTION]}
21+
packageName="@hyper-fetch/core"
22+
packageOptions={{} as any}
23+
npmName="@hyper-fetch/core"
24+
pluginOptions={{} as any}
25+
/>,
26+
);
27+
28+
[
29+
"Request",
30+
"Response",
31+
"Payload",
32+
"QueryParams",
33+
"LocalError",
34+
"Endpoint",
35+
"Client",
36+
"HasPayload",
37+
"HasParams",
38+
"HasQuery",
39+
].forEach((name) => expect(container.innerHTML).toInclude(name));
40+
});
41+
});

packages/core/src/pages/components/__tests__/type.spec.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,10 @@ describe("It should render correct type", () => {
7878
/>,
7979
);
8080

81-
expect(container).toMatchSnapshot();
82-
// expect(container.innerHTML).toInclude("xs");
83-
// expect(container.innerHTML).toInclude("sm");
84-
// expect(container.innerHTML).toInclude("md");
85-
// expect(container.innerHTML).toInclude("lg");
86-
// expect(container.innerHTML).toInclude("xl");
81+
expect(container.innerHTML).toInclude("xs");
82+
expect(container.innerHTML).toInclude("sm");
83+
expect(container.innerHTML).toInclude("md");
84+
expect(container.innerHTML).toInclude("lg");
85+
expect(container.innerHTML).toInclude("xl");
8786
});
8887
});

0 commit comments

Comments
 (0)