module.exports = function () { var html2ooxml = require('../src/lib/html2ooxml'); var utils = require('../src/lib/utils'); describe('Lib functions Suite Tests', () => { describe('Name format validation tests', () => { it('Valid Filename', () => { var filename = 'Vulnerability 1'; var result = utils.validFilename(filename); expect(result).toEqual(true); }); it('Valid Latin Filename', () => { var filename = 'Vulnerabilité 1'; var result = utils.validFilename(filename); expect(result).toEqual(true); }); it('Valid Latvian Filename', () => { var filename = 'Pažeidžiamumas 1'; var result = utils.validFilename(filename); expect(result).toEqual(true); }); it('Valid Filename with special chars', () => { var filename = 'Vulnerability_1-test'; var result = utils.validFilename(filename); expect(result).toEqual(true); }); it('Invalid Filename', () => { var filename = ' 1'; var result = utils.validFilename(filename); expect(result).toEqual(false); }); }); describe('html2ooxml tests', () => { it('Simple Paragraph', () => { var html = '

Paragraph Text

'; var expected = `Paragraph Text`; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Text without tag', () => { var html = 'Paragraph Text'; var expected = `Paragraph Text`; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Bold without wrapping paragraph', () => { var html = 'Paragraph Bold'; var expected = ''; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Bold', () => { var html = '

Paragraph Bold

'; var expected = `` + `` + `Paragraph ` + `` + `` + `` + `` + `` + `` + `Bold` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Italic', () => { var html = '

Paragraph Italic

'; var expected = `` + `` + `Paragraph ` + `` + `` + `` + `` + `` + `` + `Italic` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Underline', () => { var html = '

Paragraph Underline

'; var expected = `` + `` + `Paragraph ` + `` + `` + `` + `` + `` + `Underline` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Strike', () => { var html = '

Paragraph Strike

'; var expected = `` + `` + `Paragraph ` + `` + `` + `` + `` + `` + `Strike` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Bold and Italics', () => { var html = '

Paragraph Mark

'; var expected = `` + `` + `Paragraph ` + `` + `` + `` + `` + `` + `` + `` + `` + `Mark` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('All marks', () => { var html = '

Paragraph Mark

'; var expected = `` + `` + `Paragraph ` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `Mark` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Heading 1', () => { var html = '

Heading

'; var expected = `` + `` + `` + `` + `` + `Heading` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Heading 2', () => { var html = '

Heading

'; var expected = `` + `` + `` + `` + `` + `Heading` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Heading 3', () => { var html = '

Heading

'; var expected = `` + `` + `` + `` + `` + `Heading` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Heading 4', () => { var html = '

Heading

'; var expected = `` + `` + `` + `` + `` + `Heading` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Heading 5', () => { var html = '
Heading
'; var expected = `` + `` + `` + `` + `` + `Heading` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Heading 6', () => { var html = '
Heading
'; var expected = `` + `` + `` + `` + `` + `Heading` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Simple Bullets', () => { var html = ``; var expected = `` + `` + `` + `` + `` + `` + `` + `` + `` + `Bullet1` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `Bullet2` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Simple Bullets without ul tag', () => { var html = `
  • ` + `

    Bullet1

    ` + `
  • ` + `
  • ` + `

    Bullet2

    ` + `
  • `; var expected = `` + `` + `` + `` + `` + `` + `` + `` + `` + `Bullet1` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `Bullet2` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Nested Bullets', () => { var html = ``; var expected = `` + `` + `` + `` + `` + `` + `` + `` + `` + `Bullet1` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `BulletNested` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `Bullet2` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Simple Numbering', () => { var html = `
      ` + `
    1. ` + `

      Number1

      ` + `
    2. ` + `
    3. ` + `

      Number2

      ` + `
    4. ` + `
    `; var expected = `` + `` + `` + `` + `` + `` + `` + `` + `` + `Number1` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `Number2` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Nested Numbering', () => { var html = `
      ` + `
    1. ` + `

      Number1

      ` + `
    2. ` + `
        ` + `
      1. ` + `

        NumberNested

        ` + `
      2. ` + `
      ` + `
    3. ` + `

      Number2

      ` + `
    4. ` + `
    `; var expected = `` + `` + `` + `` + `` + `` + `` + `` + `` + `Number1` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `NumberNested` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `` + `Number2` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Break', () => { var html = '

    Paragraph
    Break

    '; var expected = `` + `` + `Paragraph` + `` + `` + `` + `` + `` + `Break` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Break with newline', () => { var html = '

    Paragraph\nBreak

    '; var expected = `` + `` + `Paragraph` + `` + `` + `` + `` + `` + `Break` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('Code', () => { var html = '

    Paragraph Code Paragraph

    '; var expected = `` + `` + `Paragraph ` + `` + `` + `` + `` + `` + `Code` + `` + `` + ` Paragraph` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); it('CodeBlock', () => { var html = '
    Code Block
    '; var expected = `` + `` + `` + `` + `` + `` + `` + `` + `Code Block` + `` + ``; var ooxml = html2ooxml(html); expect(ooxml).toEqual(expected); }); }); }); };