import { convertDescriptionWithNewSort } from '~/issues/show/utils'; describe('app/assets/javascripts/issues/show/utils.js', () => { describe('convertDescriptionWithNewSort', () => { it('converts markdown description with nested lists with new list sort order', () => { const description = `I am text - Item 1 - Item 2 - Item 3 - Item 4 - Item 5`; // Drag Item 2 + children to Item 1's position const html = ``; const list = document.createElement('div'); list.innerHTML = html; const expected = `I am text - Item 2 - Item 3 - Item 4 - Item 1 - Item 5`; expect(convertDescriptionWithNewSort(description, list.firstChild)).toBe(expected); }); it('converts markdown description with multi-line list items with new list sort order', () => { const description = `Labore ea omnis et officia excepturi. 1. Item 1 Item 1 part 2 1. Item 2 - Item 2.1 - Item 2.1.1 - Item 2.1.2 - Item 2.2 - Item 2.3 1. Item 3 1. Item 4 \`\`\` const variable = 'string'; \`\`\` ![iii](img.jpg) last paragraph 1. Item 5 1. Item 6`; // Drag Item 2 + children to Item 5's position const html = `
  1. Item 1

    Item 1 part 2

  2. Item 3

  3. Item 4

                  const variabl = 'string';
                

    description

    last paragraph

  4. Item 5

  5. Item 2

  6. Item 6

`; const list = document.createElement('div'); list.innerHTML = html; const expected = `Labore ea omnis et officia excepturi. 1. Item 1 Item 1 part 2 1. Item 3 1. Item 4 \`\`\` const variable = 'string'; \`\`\` ![iii](img.jpg) last paragraph 1. Item 5 1. Item 2 - Item 2.1 - Item 2.1.1 - Item 2.1.2 - Item 2.2 - Item 2.3 1. Item 6`; expect(convertDescriptionWithNewSort(description, list.firstChild)).toBe(expected); }); }); });