jeudi 12 décembre 2019

Test Text to HTML converting JavaScript funtion

I found a JavaScript function which converts text to HTML. Here is the function

export default function ToText(node) {
  let tag = document.createElement("div");
  tag.innerHTML = node;
  node = tag.innerText;
  return node;
} 

I tried to test the function I couldn't. Here is my Testing script

import ToText from '../ToText';

it('check whether ToText function is working or not', () => {
  const a = "<P>This is a mock test for this function.</P>";
  const b = `This is a mock test for this function`;

  expect(ToText(a)).toBe(b);
});

Why is this not correct? How can I change the code to work?J

Aucun commentaire:

Enregistrer un commentaire