diff --git a/tests/karma/core/pdf.service.test.js b/tests/karma/core/pdf.service.test.js deleted file mode 100644 index 009af7bc5..000000000 --- a/tests/karma/core/pdf.service.test.js +++ /dev/null @@ -1,316 +0,0 @@ -describe('pdf', function () { - - beforeEach(module('OpenSlidesApp.core.pdf')); - beforeEach(module('OpenSlidesApp.motions.lineNumbering')); - - var PdfMakeConverter, - lineNumberingService; - - beforeEach(inject(function (_PdfMakeConverter_, _lineNumberingService_) { - PdfMakeConverter = _PdfMakeConverter_; - lineNumberingService = _lineNumberingService_; - })); - - var defaultmargin = [0, 5], - emptyline = JSON.stringify({ - "stack": [ - {"text": [], "margin": defaultmargin}] - - }); - - - describe('converting html to pdfmake', function () { - it('converts a simple html string', function () { - var instance = PdfMakeConverter.createInstance(); - var pdfmake = instance.convertHTML( - '
Hello strong world
', 'none' - ); - expect(JSON.stringify(pdfmake[0])).toBe(emptyline); - expect(JSON.stringify(pdfmake[1])).toBe(JSON.stringify({ - "stack": [ - { - "text": [ - {"text": "Hello "}, - {"text": "strong", "bold": true}, - {"text": " world"} - ], "margin": defaultmargin - } - ] - })); - expect(JSON.stringify(pdfmake[2])).toBe(emptyline); - }); - - - it('converts a simple list', function () { - var instance = PdfMakeConverter.createInstance(); - var pdfmake = instance.convertHTML( - 'Test Test2 Test3
", - numberedHtml = lineNumberingService.insertLineNumbers(inHtml, 5); - var instance = PdfMakeConverter.createInstance(); - var pdfmake = instance.convertHTML(numberedHtml, 'outside'); - - expect(JSON.stringify(pdfmake[0])).toBe(emptyline); - expect(JSON.stringify(pdfmake[1])).toBe(JSON.stringify({ - "stack": [{"text": [], "margin": [0, 5]}, { - "columns": [{ - "width": 20, - "text": "1", - "color": "gray", - "fontSize": 8, - "margin": [0, 2, 0, 0] - }, {"text": [{"text": "Test "}]}] - }, {"text": []}, { - "columns": [{ - "width": 20, - "text": "2", - "color": "gray", - "fontSize": 8, - "margin": [0, 2, 0, 0] - }, {"text": [{"text": "Test2 "}]}] - }, {"text": []}, { - "columns": [{ - "width": 20, - "text": "3", - "color": "gray", - "fontSize": 8, - "margin": [0, 2, 0, 0] - }, {"text": [{"text": "Test3"}]}] - }] - })); - expect(JSON.stringify(pdfmake[2])).toBe(emptyline); - }); - - it('converts a list including line numbers (outside)', function () { - var inHtml = "tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
', - numberedHtml = lineNumberingService.insertLineNumbers(inHtml, 80); - - var instance = PdfMakeConverter.createInstance(); - var pdfmake = instance.convertHTML(numberedHtml, 'outside'); - expect(JSON.stringify(pdfmake[1])).toBe(JSON.stringify( - { - "stack": [ - {"text": [], "margin": [0, 5]}, - { - "columns": [ - { - "width": 20, - "text": "1", - "color": "gray", - "fontSize": 8, - "margin": [0, 2, 0, 0] - }, - { - "text": [ - {"text": "tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. "}, - {"text": "At ", "bold": true} - ] - } - ] - }, - {"text": []}, - { - "columns": [ - { - "width": 20, - "text": "2", - "color": "gray", - "fontSize": 8, - "margin": [0, 2, 0, 0] - }, - { - "text": [ - {"text": "vero eos et accusam", "bold": true}, - {"text": " et justo duo dolores et ea rebum."} - ] - } - ] - } - ] - } - )); - }); - - it('handles line breaks inside inline elements (inline)', function() { - var inHtml = 'tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
', - numberedHtml = lineNumberingService.insertLineNumbers(inHtml, 80); - - var instance = PdfMakeConverter.createInstance(); - var pdfmake = instance.convertHTML(numberedHtml, 'inline'); - expect(JSON.stringify(pdfmake[1])).toBe(JSON.stringify( - {"stack": [ - {"text": [ - {"text": "1", "color": "gray", "fontSize": 5 }, - {"text": "tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. "}, - {"text": "At ", "bold": true }, - {"text": "2", "color": "gray", "fontSize": 5}, - {"text": "vero eos et accusam", "bold": true }, - {"text": " et justo duo dolores et ea rebum."} - ], "margin": [0, 5] - } - ]} - )); - }); - - it('handles line breaks inside lists', function() { - var inHtml = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
', - numberedHtml = lineNumberingService.insertLineNumbers(inHtml, 80) - - var instance = PdfMakeConverter.createInstance(); - var pdfmake = instance.convertHTML(numberedHtml, 'outside'); - expect(JSON.stringify(pdfmake[1])).toBe(JSON.stringify( - { - "stack": [ - {"text": [], "margin": [0, 5]}, - { - "columns": [ - { "width": 20, "text": "1", "color": "gray", "fontSize": 8, "margin": [0, 2, 0, 0]}, - { "text": [ - { "text": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod ", "bold": true } - ]} - ] - }, - {"text":[]}, - { - "columns": [ - { "width": 20, "text": "2", "color": "gray", "fontSize": 8, "margin": [0, 2, 0, 0] }, - { "text": [ - { "text": "tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.", "bold": true } - ]} - ] - } - ] - } - )); - }); - }); -}); -