import { transformMsDesktop, transformMsCould } from "../../utilities/paste_transform"; import "../helpers"; const uglifyHtml = (html) => html.replace(/[\r\n]+\s+/g, " ").replace(/>\s+<").trim(); describe("transformMsDesktop", () => { const transform = (html) => { return uglifyHtml(transformMsDesktop(html)); }; it("transforms flat lists to correct list hierarchy", () => { const content = `

1.       First item

a.       Subitem 1.1

b.       Subitem 1.2

2.       Second item

a.       Subitem 2.1

b.       Subitem 2.2

`; expect(transform(content)).toMatchHtml(`
  1. First item

    1. Subitem 1.1

    2. Subitem 1.2

  2. Second item

    1. Subitem 2.1

    2. Subitem 2.2

`); }); it("transforms flat lists with a single item to a list", () => { const content = `

1.       Single item list

`; expect(transform(content)).toMatchHtml(` `); }); }); describe("transformMsCould", () => { const transform = (html) => { return uglifyHtml(transformMsCould(html)); }; it("corrects the list hierarchy", () => { const content = `
  1. Item 1

  1. Subitem 1.1

  1. Subitem 1.2

  1. Item 2

  1. Subitem 2.1

`; expect(transform(content)).toMatchHtml(`
  1. Item 1

    1. Subitem 1.1

    2. Subitem 1.2

  2. Item 2

    1. Subitem 2.1

`); }); // Checks that in case the list level "jumps" over one level, it is handled // correctly. it("corrects the missing list levels", () => { const content = `
  1. Item 1

  1. Subitem 1.1

  1. Subitem 1.2

  1. Item 2

  1. Subitem 2.1

`; expect(transform(content)).toMatchHtml(`
  1. Item 1

    1. Subitem 1.1

    2. Subitem 1.2

  2. Item 2

    1. Subitem 2.1

`); }); });