Skip to content

Commit

Permalink
Upgrade all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Apr 26, 2020
1 parent 04605f9 commit 573f4cd
Show file tree
Hide file tree
Showing 3 changed files with 2,914 additions and 2,247 deletions.
43 changes: 23 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,31 @@
"react": ">=0.14.9"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/plugin-transform-react-jsx": "^7.3.0",
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-flow-strip-types": "^7.9.0",
"@babel/plugin-transform-object-assign": "^7.8.3",
"@babel/plugin-transform-react-jsx": "^7.9.4",
"@babel/preset-env": "^7.9.5",
"@babel/preset-flow": "^7.9.0",
"@babel/preset-react": "^7.9.4",
"@testing-library/react": "^10.0.3",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^24.9.0",
"babel-plugin-macros": "^2.6.1",
"codegen.macro": "^3.0.0",
"flow-bin": "^0.108.0",
"globby": "^10.0.1",
"husky": "^3.0.5",
"jest": "^24.9.0",
"lint-staged": "^9.4.0",
"babel-jest": "^25.4.0",
"babel-plugin-macros": "^2.8.0",
"codegen.macro": "^4.0.0",
"flow-bin": "^0.123.0",
"globby": "^11.0.0",
"husky": "^4.2.5",
"jest": "^25.4.0",
"lint-staged": "^10.1.7",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"prismjs": "^1.17.1",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-testing-library": "^8.0.1",
"rollup": "^1.21.4",
"rollup-plugin-babel": "^4.3.3",
"prettier": "^2.0.5",
"prismjs": "^1.20.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"rollup": "^2.7.2",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-buble": "^0.19.8",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
Expand Down
338 changes: 169 additions & 169 deletions src/components/__tests__/Highlight.test.js
Original file line number Diff line number Diff line change
@@ -1,169 +1,169 @@
import React from "react";
import { render, cleanup } from "react-testing-library";

import Highlight from "../Highlight";
import defaultProps from "../../defaultProps";

const exampleCode = `
(function someDemo() {
var test = "Hello World!";
console.log(test);
})();
return () => <App />;
`.trim();

describe("<Highlight />", () => {
afterEach(cleanup);

describe("snapshots", () => {
it("renders correctly", () => {
const { container } = render(
<Highlight {...defaultProps} code={exampleCode} language="jsx">
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className} style={style}>
{tokens.map((line, i) => (
<div {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span {...getTokenProps({ token, key })} />
))}
</div>
))}
</pre>
)}
</Highlight>
);

expect(container).toMatchSnapshot();
});

it("renders unsupported languages correctly", () => {
const { container } = render(
<Highlight
{...defaultProps}
code={exampleCode}
language="abcdefghijklmnop"
>
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className} style={style}>
{tokens.map((line, i) => (
<div {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span {...getTokenProps({ token, key })} />
))}
</div>
))}
</pre>
)}
</Highlight>
);

expect(container).toMatchSnapshot();
});

it("renders without style props when no theme is passed", () => {
const { container } = render(
<Highlight
{...defaultProps}
theme={undefined}
code={exampleCode}
language="jsx"
>
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className} style={style}>
{tokens.map((line, i) => (
<div {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span {...getTokenProps({ token, key })} />
))}
</div>
))}
</pre>
)}
</Highlight>
);

expect(container.innerHTML.includes("style")).toBeFalsy();
});
});

describe("getLineProps", () => {
it("transforms lineProps inputs correctly", () => {
const input = {
key: "line-1",
style: { cssProp: "test" },
className: "line-class",
line: [{ types: ["punctuation"], content: "!" }],
restPropsTest: true
};

render(
<Highlight {...defaultProps} code={exampleCode} language="jsx">
{({ getLineProps }) => {
const output = getLineProps(input);

expect(output).toEqual({
key: "line-1",
style: {
cssProp: "test",
backgroundColor: null,
color: expect.any(String)
},
className: "token-line line-class",
restPropsTest: true
});

return null;
}}
</Highlight>
);
});
});

describe("getTokenProps", () => {
it("transforms tokenProps inputs correctly", () => {
const input = {
key: "token-1",
style: { cssProp: "test" },
className: "token-class",
token: { types: ["punctuation"], content: "!" },
restPropsTest: true
};

render(
<Highlight {...defaultProps} code={exampleCode} language="jsx">
{({ getTokenProps }) => {
const output = getTokenProps(input);

expect(output).toEqual({
key: "token-1",
style: { cssProp: "test", color: expect.any(String) },
className: "token punctuation token-class",
restPropsTest: true,
children: "!"
});

return null;
}}
</Highlight>
);
});

it("transforms constructor token style correctly", () => {
// From https://github.com/FormidableLabs/prism-react-renderer/issues/11
render(
<Highlight {...defaultProps} code={"open Common;"} language="reason">
{({ tokens, getTokenProps }) => {
const line = tokens[0];
const token = line[2];
const output = getTokenProps({ token, key: 2 });

expect(typeof output.style).not.toBe("function");

return null;
}}
</Highlight>
);
});
});
});
import React from "react";
import { render, cleanup } from "@testing-library/react";

import Highlight from "../Highlight";
import defaultProps from "../../defaultProps";

const exampleCode = `
(function someDemo() {
var test = "Hello World!";
console.log(test);
})();
return () => <App />;
`.trim();

describe("<Highlight />", () => {
afterEach(cleanup);

describe("snapshots", () => {
it("renders correctly", () => {
const { container } = render(
<Highlight {...defaultProps} code={exampleCode} language="jsx">
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className} style={style}>
{tokens.map((line, i) => (
<div {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span {...getTokenProps({ token, key })} />
))}
</div>
))}
</pre>
)}
</Highlight>
);

expect(container).toMatchSnapshot();
});

it("renders unsupported languages correctly", () => {
const { container } = render(
<Highlight
{...defaultProps}
code={exampleCode}
language="abcdefghijklmnop"
>
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className} style={style}>
{tokens.map((line, i) => (
<div {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span {...getTokenProps({ token, key })} />
))}
</div>
))}
</pre>
)}
</Highlight>
);

expect(container).toMatchSnapshot();
});

it("renders without style props when no theme is passed", () => {
const { container } = render(
<Highlight
{...defaultProps}
theme={undefined}
code={exampleCode}
language="jsx"
>
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className} style={style}>
{tokens.map((line, i) => (
<div {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span {...getTokenProps({ token, key })} />
))}
</div>
))}
</pre>
)}
</Highlight>
);

expect(container.innerHTML.includes("style")).toBeFalsy();
});
});

describe("getLineProps", () => {
it("transforms lineProps inputs correctly", () => {
const input = {
key: "line-1",
style: { cssProp: "test" },
className: "line-class",
line: [{ types: ["punctuation"], content: "!" }],
restPropsTest: true,
};

render(
<Highlight {...defaultProps} code={exampleCode} language="jsx">
{({ getLineProps }) => {
const output = getLineProps(input);

expect(output).toEqual({
key: "line-1",
style: {
cssProp: "test",
backgroundColor: null,
color: expect.any(String),
},
className: "token-line line-class",
restPropsTest: true,
});

return null;
}}
</Highlight>
);
});
});

describe("getTokenProps", () => {
it("transforms tokenProps inputs correctly", () => {
const input = {
key: "token-1",
style: { cssProp: "test" },
className: "token-class",
token: { types: ["punctuation"], content: "!" },
restPropsTest: true,
};

render(
<Highlight {...defaultProps} code={exampleCode} language="jsx">
{({ getTokenProps }) => {
const output = getTokenProps(input);

expect(output).toEqual({
key: "token-1",
style: { cssProp: "test", color: expect.any(String) },
className: "token punctuation token-class",
restPropsTest: true,
children: "!",
});

return null;
}}
</Highlight>
);
});

it("transforms constructor token style correctly", () => {
// From https://github.com/FormidableLabs/prism-react-renderer/issues/11
render(
<Highlight {...defaultProps} code={"open Common;"} language="reason">
{({ tokens, getTokenProps }) => {
const line = tokens[0];
const token = line[2];
const output = getTokenProps({ token, key: 2 });

expect(typeof output.style).not.toBe("function");

return null;
}}
</Highlight>
);
});
});
});
Loading

0 comments on commit 573f4cd

Please sign in to comment.