huridocs/uwazi

View on GitHub
app/react/Markdown/specs/__snapshots__/MarkdownViewer.spec.js.snap

Summary

Maintainability
Test Coverage
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MarkdownViewer limited markdown should keep allowed tags custom hook 1`] = `
<div
  className="markdown-viewer"
>
  <p>
    <cejilchart002 />
  </p>
  

</div>
`;

exports[`MarkdownViewer limited markdown should keep allowed tags custom tags 1`] = `
<div
  className="markdown-viewer"
>
  <p>
    <MarkdownLink
      classname=""
      url="the_url"
    >
      label
    </MarkdownLink>
     and
  </p>
  

  <div>
    test
  </div>
</div>
`;

exports[`MarkdownViewer limited markdown should keep allowed tags interpolation 1`] = `
<div
  className="markdown-viewer"
>
  <p>
    \${template.color}
  </p>
  

</div>
`;

exports[`MarkdownViewer limited markdown should keep allowed tags media 1`] = `
<div
  className="markdown-viewer"
>
  <div>
    <MarkdownMedia
      compact={false}
      config="(1234, options)"
    />
  </div>
  

</div>
`;

exports[`MarkdownViewer limited markdown should keep allowed tags placeholder 1`] = `
<div
  className="markdown-viewer"
>
  <p>
    <placeholder>
      $content
    </placeholder>
  </p>
  

</div>
`;

exports[`MarkdownViewer limited markdown should keep allowed tags standard tags 1`] = `
<div
  className="markdown-viewer"
>
  <table>
    <tr>
      <th>
        Title
      </th>
    </tr>
    <tr>
      <td>
        value
      </td>
    </tr>
  </table>
</div>
`;

exports[`MarkdownViewer limited markdown should replace banned tags forbidden tag 1`] = `
<div
  className="markdown-viewer"
>
  <div>
    This  was cleaned
  </div>
</div>
`;

exports[`MarkdownViewer limited markdown should replace banned tags forbidden tag 2`] = `
<div
  className="markdown-viewer"
>
  <div>
    This  was cleaned
  </div>
</div>
`;

exports[`MarkdownViewer limited markdown should replace banned tags malicious code 1`] = `
<div
  className="markdown-viewer"
>
  <img />
</div>
`;

exports[`MarkdownViewer render should be able to render properly custom components not separated by \\n\\n 1`] = `
<div
  className="markdown-viewer"
>
  <div>
    <MarkdownMedia
      compact={false}
      config="(youtubeUrl)"
    />
  </div>
  

  <div>
    <MarkdownMedia
      compact={false}
      config="(mediaUrl)"
    />
  </div>
  

</div>
`;

exports[`MarkdownViewer render should not render html by default 1`] = `
<div
  className="markdown-viewer"
>
  <p>
    &lt;div&gt;&lt;h1&gt;should be all a escaped string&lt;/h1&gt;&lt;/div&gt;
  </p>
  

</div>
`;

exports[`MarkdownViewer render should remove Dataset and Query tags 1`] = `
<div
  className="markdown-viewer"
>
  <p>
    test
  </p>
  

  

  

  <SearchBox
    classname=""
    placeholder=""
  />
  

  

  <div>
    test
  </div>
</div>
`;

exports[`MarkdownViewer render should remove whitespaces between table tags (to prevent react warning) 1`] = `
<div
  className="markdown-viewer"
>
  <table>
    <thead>
      <tr>
        <th>
          cadh
        </th>
        <th>
          cbdp
        </th>
        <th>
          cidfp
        </th>
        <th>
          cipst
        </th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>
          1.1,25.1
        </td>
        <td />
        <td />
        <td />
      </tr>
      <tr>
        <td>
          1.1,21.1,21.2,25,1
        </td>
        <td />
        <td />
        <td />
      </tr>
    </tbody>
  </table>
  

</div>
`;

exports[`MarkdownViewer render should render Link 1`] = `
<div
  className="markdown-viewer"
>
  <MarkdownLink
    classname=""
    label="this is a label"
    url="this_is_the_url"
  />
  

  <p>
    <MarkdownLink
      classname=""
      url="the_url"
    >
      label
    </MarkdownLink>
  </p>
  

</div>
`;

exports[`MarkdownViewer render should render a searchbox 1`] = `
<div
  className="markdown-viewer"
>
  <SearchBox
    classname=""
    placeholder="this is a placeholder"
  />
  

</div>
`;

exports[`MarkdownViewer render should render customHook components and show an error for invalid ones 1`] = `
<div
  className="markdown-viewer"
>
  <customComponent
    array={
      Array [
        Object {
          "bool": true,
          "child": Array [
            "a",
          ],
        },
        Object {
          "child": Array [
            "b",
          ],
        },
      ]
    }
    component="validcomponent"
    prop="a prop"
  />
  

  <p>
    Should allow markdown between hooks
  </p>
  

  <customComponent
    component="validcomponent"
  />
  

  <p
    className="error"
  >
    <br />
    <strong>
      <i>
        <Connect(Translate)
          translationKey="Custom component error"
        >
          Custom component markup error: unsupported values! Please check your configuration
        </Connect(Translate)>
      </i>
    </strong>
    <br />
    Invalid  component
    <br />
  </p>
  

</div>
`;

exports[`MarkdownViewer render should render list components 1`] = `
<div
  className="markdown-viewer"
>
  <ItemList
    items={
      Array [
        "items1",
      ]
    }
    link="/library/param1"
    options={
      Object {
        "option1": "optionValue",
      }
    }
  />
  

  <ItemList
    items={
      Array [
        "items2",
      ]
    }
    link="/library/param2"
    options={Object {}}
  />
  

  <ItemList
    items={
      Array [
        "items3",
      ]
    }
    link="/library/param3"
    options={Object {}}
  />
  

</div>
`;

exports[`MarkdownViewer render should render markdown 1`] = `
<div
  className="markdown-viewer"
>
  <h2>
    title
  </h2>
  

  <p>
    Some text with a 
    <a
      href="http://google.com"
    >
      URL
    </a>
     inside.
  </p>
  

  <p>
    Which should be in its own line, separated with TWO line breaks (to create a new &lt;p&gt; Element)
  </p>
  

  <pre>
    <code
      className="language-javascript"
    >
      Code

    </code>
  </pre>
  

</div>
`;

exports[`MarkdownViewer render should render media components 1`] = `
<div
  className="markdown-viewer"
>
  <div>
    <MarkdownMedia
      compact={false}
      config="(1234, options)"
    />
  </div>
  

  <div>
    <MarkdownMedia
      compact={false}
      config="(1234)"
    />
  </div>
  

  <div>
    <MarkdownMedia
      compact={false}
      config="(config options)"
    />
  </div>
  

</div>
`;

exports[`MarkdownViewer render should render properly a selfclosing XML tags 1`] = `
<div
  className="markdown-viewer"
>
  <p>
    test
  </p>
  

  <SearchBox
    classname=""
    placeholder=""
  />
  

  <div>
    test
  </div>
</div>
`;

exports[`MarkdownViewer render should render single tags as self closing 1`] = `
<div
  className="markdown-viewer"
>
  <p>
    test
  </p>
  

  <hr />
  

  <p>
    test
  </p>
  

</div>
`;

exports[`MarkdownViewer render should support containers with custom classNames 1`] = `
<div
  className="markdown-viewer"
>
  <div
    className="test classname"
  >
    <p>
      text inside a div
    </p>
    

  </div>
</div>
`;

exports[`MarkdownViewer render when markdown is invalid should not render anything when its empty 1`] = `""`;

exports[`MarkdownViewer render when not valid html should not fail on malformed tags 1`] = `
<div
  className="markdown-viewer"
>
  <div />
</div>
`;

exports[`MarkdownViewer render when not valid html should not fail on unsupported tags 1`] = `
<div
  className="markdown-viewer"
>
  <p>
    <b>
      Little red ridding hood
    </b>
  </p>
  

  <p>
    I don't know 
    <div
      className="error"
    >
      Invalid tag: ..long
    </div>
  </p>
</div>
`;

exports[`MarkdownViewer render when passing html true prop should render customComponents nested inside html 1`] = `
<div
  className="markdown-viewer"
>
  <div>
    <ItemList
      items={
        Array [
          "items1",
        ]
      }
      link="/library/param1"
      options={
        Object {
          "option1": "optionValue",
        }
      }
    />
    <div>
      <div>
        <MarkdownMedia
          compact={false}
          config="(url)"
        />
      </div>
    </div>
  </div>
</div>
`;

exports[`MarkdownViewer render when passing html true prop should render html 1`] = `
<div
  className="markdown-viewer"
>
  <div>
    <h1>
      test
    </h1>
  </div>
</div>
`;