-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
203 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
**/node_modules | ||
coverage | ||
dist | ||
example/index* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
ARG NODE_VERSION=18 | ||
FROM node:${NODE_VERSION}-alpine3.18 | ||
|
||
ARG NODE_VERSION | ||
ENV NODE_VERSION=$NODE_VERSION | ||
|
||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true | ||
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser | ||
|
||
ENV USE_LEGACY=true | ||
|
||
ARG REACT_VERSION | ||
ENV REACT_VERSION=$REACT_VERSION | ||
|
||
RUN apk update && apk add \ | ||
make \ | ||
font-noto-emoji \ | ||
font-roboto \ | ||
chromium | ||
|
||
RUN npm install -g npm@latest | ||
|
||
ENV DOCKER_WORKSPACE=/markdown | ||
WORKDIR ${DOCKER_WORKSPACE} | ||
|
||
COPY package.json package-lock.json ./ | ||
RUN npm install | ||
|
||
RUN npm install react@${REACT_VERSION} react-dom@${REACT_VERSION} @testing-library/react@12 | ||
|
||
COPY . ./ | ||
|
||
RUN mkdir -p __tests__/browser/__image_snapshots__/__diff_output__ | ||
|
||
RUN make emojis | ||
|
||
EXPOSE 9966 | ||
|
||
CMD ["test.browser"] | ||
ENTRYPOINT ["npm", "run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-1.1 KB
(97%)
...render-html-blocks-style-tags-and-style-attributes-with-safe-mode-on-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.33 KB
(110%)
...regression-tests-rdmd-syntax-renders-callout-tests-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.47 KB
(100%)
...sual-regression-tests-rdmd-syntax-renders-callouts-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.67 KB
(96%)
...ression-tests-rdmd-syntax-renders-code-block-tests-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-12.4 KB
(94%)
...l-regression-tests-rdmd-syntax-renders-code-blocks-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+383 Bytes
(100%)
...visual-regression-tests-rdmd-syntax-renders-embeds-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.16 KB
(100%)
...sual-regression-tests-rdmd-syntax-renders-headings-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+422 Bytes
(100%)
...nders-html-blocks-style-tags-and-style-attributes-with-safe-mode-off-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-138 Bytes
(100%)
...visual-regression-tests-rdmd-syntax-renders-images-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-685 Bytes
(99%)
...-visual-regression-tests-rdmd-syntax-renders-lists-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-69 Bytes
(100%)
...-tests-rdmd-syntax-renders-table-of-contents-tests-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+619 Bytes
(100%)
...-regression-tests-rdmd-syntax-renders-tables-tests-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.14 KB
(99%)
...visual-regression-tests-rdmd-syntax-renders-tables-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.62 KB
(93%)
...ual-regression-tests-rdmd-syntax-renders-vars-test-without-surprises-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
const { renderToString } = require('react-dom/server'); | ||
const { render } = require('@testing-library/react'); | ||
|
||
const { react } = require('../../index'); | ||
|
||
describe('Style tag', () => { | ||
describe('safeMode = false', () => { | ||
it('renders as a style tag', () => { | ||
const md = '<style>{ background-color: salmon }</style>'; | ||
const { container } = render(react(md)); | ||
|
||
expect(renderToString(react(md))).toMatchInlineSnapshot( | ||
'"<style data-reactroot=\\"\\">{ background-color: salmon }</style>"', | ||
); | ||
expect(container.querySelector('style').innerHTML).toBe('{ background-color: salmon }'); | ||
}); | ||
}); | ||
|
||
describe('safeMode = true', () => { | ||
it('renders the style in a `<pre>`', () => { | ||
const md = '<style>{ background-color: salmon }</style>'; | ||
const { container } = render(react(md, { safeMode: true })); | ||
|
||
expect(renderToString(react(md, { safeMode: true }))).toMatchInlineSnapshot(` | ||
"<pre data-reactroot=\\"\\"><code><style> | ||
{ background-color: salmon } | ||
</style></code></pre>" | ||
`); | ||
expect(container.querySelector('pre > code').innerHTML).toBe( | ||
'<style>\n{ background-color: salmon }\n</style>', | ||
); | ||
}); | ||
|
||
it('renders the style in a `<pre>` when attrs are present', () => { | ||
const md = '<style someAttr="muahaha">{ background-color: salmon }</style>'; | ||
const { container } = render(react(md, { safeMode: true })); | ||
|
||
expect(renderToString(react(md, { safeMode: true }))).toMatchInlineSnapshot(` | ||
"<pre data-reactroot=\\"\\"><code><style> | ||
{ background-color: salmon } | ||
</style></code></pre>" | ||
`); | ||
expect(container.querySelector('pre > code').innerHTML).toBe( | ||
'<style>\n{ background-color: salmon }\n</style>', | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
const { renderToString } = require('react-dom/server'); | ||
const { render } = require('@testing-library/react'); | ||
|
||
const { react } = require('../../index'); | ||
|
||
describe('style attributes', () => { | ||
describe('safeMode = false', () => { | ||
it('renders style attributes', () => { | ||
const md = '<div style="background-color: salmon">fish content</div>'; | ||
const { container } = render(react(md)); | ||
|
||
expect(renderToString(react(md))).toMatchInlineSnapshot( | ||
'"<div style=\\"background-color:salmon\\" data-reactroot=\\"\\">fish content</div>"', | ||
); | ||
expect(container.querySelector('[style]')).toBeVisible(); | ||
}); | ||
}); | ||
|
||
describe('safeMode = true', () => { | ||
it('does not render style attributes', () => { | ||
const md = '<div style="background-color: salmon">fish content</div>'; | ||
const { container } = render(react(md, { safeMode: true })); | ||
|
||
expect(renderToString(react(md, { safeMode: true }))).toMatchInlineSnapshot( | ||
'"<div data-reactroot=\\"\\">fish content</div>"', | ||
); | ||
expect(container.querySelector('[style]')).toBeNull(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,7 @@ | ||
/* eslint-disable import/no-import-module-exports */ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { AppContainer } from 'react-hot-loader'; | ||
import { createRoot } from 'react-dom/client'; | ||
|
||
import Demo from './Demo'; | ||
|
||
function render(Component) { | ||
ReactDOM.render( | ||
<AppContainer> | ||
<Component /> | ||
</AppContainer>, | ||
document.getElementById('rdmd-demo'), | ||
); | ||
} | ||
|
||
render(Demo); | ||
|
||
// Webpack Hot Module Replacement API | ||
if (module.hot) { | ||
module.hot.accept('./Demo', () => render(Demo)); | ||
} | ||
const root = createRoot(document.getElementById('rdmd-demo')); | ||
root.render(<Demo />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint-disable import/no-import-module-exports */ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import Demo from './Demo'; | ||
|
||
ReactDOM.render(<Demo />, document.getElementById('rdmd-demo')); |
Oops, something went wrong.