Skip to content

Commit

Permalink
feat: #1123 render renderHTML for diff compare of approval modal
Browse files Browse the repository at this point in the history
Changes
- Add diff viewer for RenderHTML component
  • Loading branch information
duong-se committed May 5, 2020
1 parent 0669a93 commit dd90c9e
Show file tree
Hide file tree
Showing 20 changed files with 152 additions and 63 deletions.
2 changes: 1 addition & 1 deletion packages/cognito-auth/src/tests/badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/cognito-auth/src/tests/badges/badge-functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/cognito-auth/src/tests/badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HTMLRender should render match to snapshot 1`] = `
<Component>
<Component
className=""
>
<div
Expand Down
5 changes: 3 additions & 2 deletions packages/elements/src/components/HtmlRender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { Content } from '../Layout'
export interface HTMLRenderProps {
html: string
diffing?: boolean
className?: string
}

export const HTMLRender: React.SFC<HTMLRenderProps> = ({ html, diffing = false }: HTMLRenderProps) => {
export const HTMLRender: React.SFC<HTMLRenderProps> = ({ html, diffing = false, className = '' }: HTMLRenderProps) => {
const jsonElements = parse(html)
return <Content>{renderer(jsonElements, diffing)}</Content>
return <Content className={className}>{renderer(jsonElements, diffing)}</Content>
}
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-statements.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DiffRenderHTML should match a snapshot 1`] = `
<div>
<Component
className="undefined undefined"
html="abc"
/>
<span>
</span>
<Component
className="undefined undefined"
html="<b>axxxxxxxxxxxbc<b>"
/>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react'
import { shallow } from 'enzyme'
import DiffRenderHTML, { DiffRenderHTMLProps } from '../diff-render-html'

const props: DiffRenderHTMLProps = {
currentString: 'abc',
changedString: '<b>axxxxxxxxxxxbc<b>',
}

describe('DiffRenderHTML', () => {
it('should match a snapshot', () => {
expect(shallow(<DiffRenderHTML {...props} />)).toMatchSnapshot()
})

afterEach(() => {
jest.resetAllMocks()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ exports[`AdminRevisionModalInner should match a snapshot 1`] = `
>
Description
</h4>
<DiffViewer
<DiffRenderHTML
changedString="Download the app now and start shopping our selection of fashion, books, toys, home
appliances, sport accessories and much more.
Expand All @@ -138,7 +138,6 @@ Get
elementum integer enim neque volutpat ac tincidunt vitae semper quis lectus nulla
at volutpat diam ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet
proin fermentum leo vel orci porta non pulvinar neque laoreet suspendisse interdum co"
type="words"
/>
</div>
<div
Expand Down
Loading

0 comments on commit dd90c9e

Please sign in to comment.