From 97df9b9afc0e7aa99552b81b6872a69b7a56d105 Mon Sep 17 00:00:00 2001
From: webzwo0i
Date: Wed, 2 Dec 2020 21:53:39 +0100
Subject: [PATCH] more tests, WIP
---
.../specs/api/importexport/brDontBreakOL.html | 1 +
.../api/importexport/bulletListInOL.html | 1 +
.../importexport/bulletsAndEmptyLines.html | 1 +
.../bulletsAndNonBulletLines.html | 1 +
.../collapseSpacesAcrossNewlines.html | 5 +
.../collapseSpacesInsideElements.html | 1 +
.../specs/api/importexport/complexNest.html | 1 +
.../dontDeleteSpaceInsideElements.html | 1 +
.../ignoreAnyTagsOutsideBody.html | 1 +
.../specs/api/importexport/indents.html | 1 +
.../importexport/indentsAndEmptyLines.html | 1 +
.../api/importexport/indentsAndNewlines.html | 1 +
.../indentsAndNonIndentedLines.html | 1 +
.../api/importexport/lineDoBreakInOl.html | 1 +
.../api/importexport/lineDontBreakOL.html | 1 +
.../lineWithSpacesPreceedsOL.html | 1 +
.../api/importexport/linebreakPreceedsOL.html | 1 +
.../api/importexport/multiLineParagraph.html | 4 +
.../multiLineParagraphWithPre.html | 8 +
.../multipleIndentLevelAndStyles.html | 1 +
.../multipleNewLinesAtBeginning.html | 1 +
...ultipleParagraphsWithSpacesPreceedsOL.html | 1 +
.../specs/api/importexport/nestedOl.html | 1 +
.../specs/api/importexport/nestedOl2.html | 1 +
.../api/importexport/nestedOrderedLi.html | 14 +
.../nonBreakingSpacesAfterNewlines.html | 1 +
.../nonBreakingSpacesAfterNewlinesP.html | 1 +
.../specs/api/importexport/normalNewline.html | 1 +
tests/backend/specs/api/importexport/ol.html | 1 +
.../importexport/olWithNonDefaultStart.html | 1 +
.../api/importexport/paragraphPreceedsOL.html | 1 +
.../api/importexport/preIntroducesASpace.html | 4 +
.../api/importexport/spacesAfterNewline.html | 1 +
.../api/importexport/spacesAfterNewlineP.html | 1 +
.../api/importexport/spacesAtEndOfLine.html | 1 +
.../api/importexport/spacesAtEndOfLineP.html | 1 +
.../stylingWithAttributesAndTags.html | 1 +
.../stylingWithAttributesWithoutTags.html | 1 +
.../stylingWithFontAttributes.html | 1 +
...ylingWithSpanAndTagsWithoutAttributes.html | 1 +
.../stylingWithTagsWithoutAttributes.html | 1 +
.../backend/specs/api/importexport/testP.html | 1 +
tests/backend/specs/api/importexport/ul.html | 1 +
.../specs/api/importexport/ulIndented.html | 1 +
tests/backend/specs/contentcollector.js | 285 +++++++++++++++++-
45 files changed, 353 insertions(+), 6 deletions(-)
create mode 100644 tests/backend/specs/api/importexport/brDontBreakOL.html
create mode 100644 tests/backend/specs/api/importexport/bulletListInOL.html
create mode 100644 tests/backend/specs/api/importexport/bulletsAndEmptyLines.html
create mode 100644 tests/backend/specs/api/importexport/bulletsAndNonBulletLines.html
create mode 100644 tests/backend/specs/api/importexport/collapseSpacesAcrossNewlines.html
create mode 100644 tests/backend/specs/api/importexport/collapseSpacesInsideElements.html
create mode 100644 tests/backend/specs/api/importexport/complexNest.html
create mode 100644 tests/backend/specs/api/importexport/dontDeleteSpaceInsideElements.html
create mode 100644 tests/backend/specs/api/importexport/ignoreAnyTagsOutsideBody.html
create mode 100644 tests/backend/specs/api/importexport/indents.html
create mode 100644 tests/backend/specs/api/importexport/indentsAndEmptyLines.html
create mode 100644 tests/backend/specs/api/importexport/indentsAndNewlines.html
create mode 100644 tests/backend/specs/api/importexport/indentsAndNonIndentedLines.html
create mode 100644 tests/backend/specs/api/importexport/lineDoBreakInOl.html
create mode 100644 tests/backend/specs/api/importexport/lineDontBreakOL.html
create mode 100644 tests/backend/specs/api/importexport/lineWithSpacesPreceedsOL.html
create mode 100644 tests/backend/specs/api/importexport/linebreakPreceedsOL.html
create mode 100644 tests/backend/specs/api/importexport/multiLineParagraph.html
create mode 100644 tests/backend/specs/api/importexport/multiLineParagraphWithPre.html
create mode 100644 tests/backend/specs/api/importexport/multipleIndentLevelAndStyles.html
create mode 100644 tests/backend/specs/api/importexport/multipleNewLinesAtBeginning.html
create mode 100644 tests/backend/specs/api/importexport/multipleParagraphsWithSpacesPreceedsOL.html
create mode 100644 tests/backend/specs/api/importexport/nestedOl.html
create mode 100644 tests/backend/specs/api/importexport/nestedOl2.html
create mode 100644 tests/backend/specs/api/importexport/nestedOrderedLi.html
create mode 100644 tests/backend/specs/api/importexport/nonBreakingSpacesAfterNewlines.html
create mode 100644 tests/backend/specs/api/importexport/nonBreakingSpacesAfterNewlinesP.html
create mode 100644 tests/backend/specs/api/importexport/normalNewline.html
create mode 100644 tests/backend/specs/api/importexport/ol.html
create mode 100644 tests/backend/specs/api/importexport/olWithNonDefaultStart.html
create mode 100644 tests/backend/specs/api/importexport/paragraphPreceedsOL.html
create mode 100644 tests/backend/specs/api/importexport/preIntroducesASpace.html
create mode 100644 tests/backend/specs/api/importexport/spacesAfterNewline.html
create mode 100644 tests/backend/specs/api/importexport/spacesAfterNewlineP.html
create mode 100644 tests/backend/specs/api/importexport/spacesAtEndOfLine.html
create mode 100644 tests/backend/specs/api/importexport/spacesAtEndOfLineP.html
create mode 100644 tests/backend/specs/api/importexport/stylingWithAttributesAndTags.html
create mode 100644 tests/backend/specs/api/importexport/stylingWithAttributesWithoutTags.html
create mode 100644 tests/backend/specs/api/importexport/stylingWithFontAttributes.html
create mode 100644 tests/backend/specs/api/importexport/stylingWithSpanAndTagsWithoutAttributes.html
create mode 100644 tests/backend/specs/api/importexport/stylingWithTagsWithoutAttributes.html
create mode 100644 tests/backend/specs/api/importexport/testP.html
create mode 100644 tests/backend/specs/api/importexport/ul.html
create mode 100644 tests/backend/specs/api/importexport/ulIndented.html
diff --git a/tests/backend/specs/api/importexport/brDontBreakOL.html b/tests/backend/specs/api/importexport/brDontBreakOL.html
new file mode 100644
index 000000000..fd0bd9322
--- /dev/null
+++ b/tests/backend/specs/api/importexport/brDontBreakOL.html
@@ -0,0 +1 @@
+- should be 1
- should be 2
- should be 3
diff --git a/tests/backend/specs/api/importexport/bulletListInOL.html b/tests/backend/specs/api/importexport/bulletListInOL.html
new file mode 100644
index 000000000..52e169811
--- /dev/null
+++ b/tests/backend/specs/api/importexport/bulletListInOL.html
@@ -0,0 +1 @@
+- should be 1
- should be 2
diff --git a/tests/backend/specs/api/importexport/bulletsAndEmptyLines.html b/tests/backend/specs/api/importexport/bulletsAndEmptyLines.html
new file mode 100644
index 000000000..6f6aac94e
--- /dev/null
+++ b/tests/backend/specs/api/importexport/bulletsAndEmptyLines.html
@@ -0,0 +1 @@
+
diff --git a/tests/backend/specs/api/importexport/bulletsAndNonBulletLines.html b/tests/backend/specs/api/importexport/bulletsAndNonBulletLines.html
new file mode 100644
index 000000000..853125850
--- /dev/null
+++ b/tests/backend/specs/api/importexport/bulletsAndNonBulletLines.html
@@ -0,0 +1 @@
+not bullet
diff --git a/tests/backend/specs/api/importexport/collapseSpacesAcrossNewlines.html b/tests/backend/specs/api/importexport/collapseSpacesAcrossNewlines.html
new file mode 100644
index 000000000..69d92b522
--- /dev/null
+++ b/tests/backend/specs/api/importexport/collapseSpacesAcrossNewlines.html
@@ -0,0 +1,5 @@
+ Need
+ more
+ space
+ s
+ !
diff --git a/tests/backend/specs/api/importexport/collapseSpacesInsideElements.html b/tests/backend/specs/api/importexport/collapseSpacesInsideElements.html
new file mode 100644
index 000000000..97ad1e73f
--- /dev/null
+++ b/tests/backend/specs/api/importexport/collapseSpacesInsideElements.html
@@ -0,0 +1 @@
+Need more space s !
diff --git a/tests/backend/specs/api/importexport/complexNest.html b/tests/backend/specs/api/importexport/complexNest.html
new file mode 100644
index 000000000..51affcfe4
--- /dev/null
+++ b/tests/backend/specs/api/importexport/complexNest.html
@@ -0,0 +1 @@
+- item
- item1
- item2
diff --git a/tests/backend/specs/api/importexport/dontDeleteSpaceInsideElements.html b/tests/backend/specs/api/importexport/dontDeleteSpaceInsideElements.html
new file mode 100644
index 000000000..429d4a5c1
--- /dev/null
+++ b/tests/backend/specs/api/importexport/dontDeleteSpaceInsideElements.html
@@ -0,0 +1 @@
+Need more spaces !
diff --git a/tests/backend/specs/api/importexport/ignoreAnyTagsOutsideBody.html b/tests/backend/specs/api/importexport/ignoreAnyTagsOutsideBody.html
new file mode 100644
index 000000000..c0aee7e62
--- /dev/null
+++ b/tests/backend/specs/api/importexport/ignoreAnyTagsOutsideBody.html
@@ -0,0 +1 @@
+titleempty
diff --git a/tests/backend/specs/api/importexport/indents.html b/tests/backend/specs/api/importexport/indents.html
new file mode 100644
index 000000000..60d6151ba
--- /dev/null
+++ b/tests/backend/specs/api/importexport/indents.html
@@ -0,0 +1 @@
+
diff --git a/tests/backend/specs/api/importexport/indentsAndEmptyLines.html b/tests/backend/specs/api/importexport/indentsAndEmptyLines.html
new file mode 100644
index 000000000..73d59d0b7
--- /dev/null
+++ b/tests/backend/specs/api/importexport/indentsAndEmptyLines.html
@@ -0,0 +1 @@
+
diff --git a/tests/backend/specs/api/importexport/indentsAndNewlines.html b/tests/backend/specs/api/importexport/indentsAndNewlines.html
new file mode 100644
index 000000000..4151ec26b
--- /dev/null
+++ b/tests/backend/specs/api/importexport/indentsAndNewlines.html
@@ -0,0 +1 @@
+
diff --git a/tests/backend/specs/api/importexport/indentsAndNonIndentedLines.html b/tests/backend/specs/api/importexport/indentsAndNonIndentedLines.html
new file mode 100644
index 000000000..d9a27ad9b
--- /dev/null
+++ b/tests/backend/specs/api/importexport/indentsAndNonIndentedLines.html
@@ -0,0 +1 @@
+not indent
diff --git a/tests/backend/specs/api/importexport/lineDoBreakInOl.html b/tests/backend/specs/api/importexport/lineDoBreakInOl.html
new file mode 100644
index 000000000..592355357
--- /dev/null
+++ b/tests/backend/specs/api/importexport/lineDoBreakInOl.html
@@ -0,0 +1 @@
+- should be 1
hello
- should be 1
- should be 2
diff --git a/tests/backend/specs/api/importexport/lineDontBreakOL.html b/tests/backend/specs/api/importexport/lineDontBreakOL.html
new file mode 100644
index 000000000..f4da98f31
--- /dev/null
+++ b/tests/backend/specs/api/importexport/lineDontBreakOL.html
@@ -0,0 +1 @@
+- should be 1
- should be 2
- should be 3
diff --git a/tests/backend/specs/api/importexport/lineWithSpacesPreceedsOL.html b/tests/backend/specs/api/importexport/lineWithSpacesPreceedsOL.html
new file mode 100644
index 000000000..e2a26dbc1
--- /dev/null
+++ b/tests/backend/specs/api/importexport/lineWithSpacesPreceedsOL.html
@@ -0,0 +1 @@
+
- should be 1
diff --git a/tests/backend/specs/api/importexport/linebreakPreceedsOL.html b/tests/backend/specs/api/importexport/linebreakPreceedsOL.html
new file mode 100644
index 000000000..d12bb5a07
--- /dev/null
+++ b/tests/backend/specs/api/importexport/linebreakPreceedsOL.html
@@ -0,0 +1 @@
+
- should be 1
diff --git a/tests/backend/specs/api/importexport/multiLineParagraph.html b/tests/backend/specs/api/importexport/multiLineParagraph.html
new file mode 100644
index 000000000..5b26b2ab7
--- /dev/null
+++ b/tests/backend/specs/api/importexport/multiLineParagraph.html
@@ -0,0 +1,4 @@
+
+а б в г ґ д е є ж з и і ї й к л м н о
+п р с т у ф х ц ч ш щ ю я ь
+
diff --git a/tests/backend/specs/api/importexport/multiLineParagraphWithPre.html b/tests/backend/specs/api/importexport/multiLineParagraphWithPre.html
new file mode 100644
index 000000000..4b00fe1c8
--- /dev/null
+++ b/tests/backend/specs/api/importexport/multiLineParagraphWithPre.html
@@ -0,0 +1,8 @@
+
+а б в г ґ д е є ж з и і ї й к л м н о
multiple
+lines
+in
+pre
+
п р с т у ф х ц ч ш щ ю я
+ь
+
diff --git a/tests/backend/specs/api/importexport/multipleIndentLevelAndStyles.html b/tests/backend/specs/api/importexport/multipleIndentLevelAndStyles.html
new file mode 100644
index 000000000..7f1e843d2
--- /dev/null
+++ b/tests/backend/specs/api/importexport/multipleIndentLevelAndStyles.html
@@ -0,0 +1 @@
+
indent4 line 2 bisuindent4 line 2 bs- indent4 line 2 u
uis
diff --git a/tests/backend/specs/api/importexport/multipleNewLinesAtBeginning.html b/tests/backend/specs/api/importexport/multipleNewLinesAtBeginning.html
new file mode 100644
index 000000000..dcfc783b9
--- /dev/null
+++ b/tests/backend/specs/api/importexport/multipleNewLinesAtBeginning.html
@@ -0,0 +1 @@
+
first line
second line
diff --git a/tests/backend/specs/api/importexport/multipleParagraphsWithSpacesPreceedsOL.html b/tests/backend/specs/api/importexport/multipleParagraphsWithSpacesPreceedsOL.html
new file mode 100644
index 000000000..9df0d3fa5
--- /dev/null
+++ b/tests/backend/specs/api/importexport/multipleParagraphsWithSpacesPreceedsOL.html
@@ -0,0 +1 @@
+
- should be 1
diff --git a/tests/backend/specs/api/importexport/nestedOl.html b/tests/backend/specs/api/importexport/nestedOl.html
new file mode 100644
index 000000000..49293d19f
--- /dev/null
+++ b/tests/backend/specs/api/importexport/nestedOl.html
@@ -0,0 +1 @@
+a- b
- c
notlistfoo
diff --git a/tests/backend/specs/api/importexport/nestedOl2.html b/tests/backend/specs/api/importexport/nestedOl2.html
new file mode 100644
index 000000000..8ba258656
--- /dev/null
+++ b/tests/backend/specs/api/importexport/nestedOl2.html
@@ -0,0 +1 @@
+
diff --git a/tests/backend/specs/api/importexport/nestedOrderedLi.html b/tests/backend/specs/api/importexport/nestedOrderedLi.html
new file mode 100644
index 000000000..754b39547
--- /dev/null
+++ b/tests/backend/specs/api/importexport/nestedOrderedLi.html
@@ -0,0 +1,14 @@
+
+
+
+
+ - one
+ -
+
+ - 1.1
+
+
+ - two
+
+
+
diff --git a/tests/backend/specs/api/importexport/nonBreakingSpacesAfterNewlines.html b/tests/backend/specs/api/importexport/nonBreakingSpacesAfterNewlines.html
new file mode 100644
index 000000000..173af0075
--- /dev/null
+++ b/tests/backend/specs/api/importexport/nonBreakingSpacesAfterNewlines.html
@@ -0,0 +1 @@
+something
something
diff --git a/tests/backend/specs/api/importexport/nonBreakingSpacesAfterNewlinesP.html b/tests/backend/specs/api/importexport/nonBreakingSpacesAfterNewlinesP.html
new file mode 100644
index 000000000..e2828efcd
--- /dev/null
+++ b/tests/backend/specs/api/importexport/nonBreakingSpacesAfterNewlinesP.html
@@ -0,0 +1 @@
+something something
diff --git a/tests/backend/specs/api/importexport/normalNewline.html b/tests/backend/specs/api/importexport/normalNewline.html
new file mode 100644
index 000000000..c4843e223
--- /dev/null
+++ b/tests/backend/specs/api/importexport/normalNewline.html
@@ -0,0 +1 @@
+line1
line2
diff --git a/tests/backend/specs/api/importexport/ol.html b/tests/backend/specs/api/importexport/ol.html
new file mode 100644
index 000000000..849d9f9cc
--- /dev/null
+++ b/tests/backend/specs/api/importexport/ol.html
@@ -0,0 +1 @@
+- a
- b
- c
test
diff --git a/tests/backend/specs/api/importexport/olWithNonDefaultStart.html b/tests/backend/specs/api/importexport/olWithNonDefaultStart.html
new file mode 100644
index 000000000..2450b2358
--- /dev/null
+++ b/tests/backend/specs/api/importexport/olWithNonDefaultStart.html
@@ -0,0 +1 @@
+- 6
- 7
- 4
- 5
- 0.0.9
- 0.0.10
diff --git a/tests/backend/specs/api/importexport/paragraphPreceedsOL.html b/tests/backend/specs/api/importexport/paragraphPreceedsOL.html
new file mode 100644
index 000000000..ac6c04e3f
--- /dev/null
+++ b/tests/backend/specs/api/importexport/paragraphPreceedsOL.html
@@ -0,0 +1 @@
+- should be 1
diff --git a/tests/backend/specs/api/importexport/preIntroducesASpace.html b/tests/backend/specs/api/importexport/preIntroducesASpace.html
new file mode 100644
index 000000000..ae27074fc
--- /dev/null
+++ b/tests/backend/specs/api/importexport/preIntroducesASpace.html
@@ -0,0 +1,4 @@
+
+ 1
+
preline
+
diff --git a/tests/backend/specs/api/importexport/spacesAfterNewline.html b/tests/backend/specs/api/importexport/spacesAfterNewline.html
new file mode 100644
index 000000000..46563145b
--- /dev/null
+++ b/tests/backend/specs/api/importexport/spacesAfterNewline.html
@@ -0,0 +1 @@
+something
something
diff --git a/tests/backend/specs/api/importexport/spacesAfterNewlineP.html b/tests/backend/specs/api/importexport/spacesAfterNewlineP.html
new file mode 100644
index 000000000..c837d2bb8
--- /dev/null
+++ b/tests/backend/specs/api/importexport/spacesAfterNewlineP.html
@@ -0,0 +1 @@
+something something
diff --git a/tests/backend/specs/api/importexport/spacesAtEndOfLine.html b/tests/backend/specs/api/importexport/spacesAtEndOfLine.html
new file mode 100644
index 000000000..d05be1b17
--- /dev/null
+++ b/tests/backend/specs/api/importexport/spacesAtEndOfLine.html
@@ -0,0 +1 @@
+something
something
diff --git a/tests/backend/specs/api/importexport/spacesAtEndOfLineP.html b/tests/backend/specs/api/importexport/spacesAtEndOfLineP.html
new file mode 100644
index 000000000..a9f866e00
--- /dev/null
+++ b/tests/backend/specs/api/importexport/spacesAtEndOfLineP.html
@@ -0,0 +1 @@
+something something
diff --git a/tests/backend/specs/api/importexport/stylingWithAttributesAndTags.html b/tests/backend/specs/api/importexport/stylingWithAttributesAndTags.html
new file mode 100644
index 000000000..7c708c776
--- /dev/null
+++ b/tests/backend/specs/api/importexport/stylingWithAttributesAndTags.html
@@ -0,0 +1 @@
+line
bold strikethrough italic underline no style no style
diff --git a/tests/backend/specs/api/importexport/stylingWithAttributesWithoutTags.html b/tests/backend/specs/api/importexport/stylingWithAttributesWithoutTags.html
new file mode 100644
index 000000000..17a77dd16
--- /dev/null
+++ b/tests/backend/specs/api/importexport/stylingWithAttributesWithoutTags.html
@@ -0,0 +1 @@
+line
bold strikethrough italic underline no style no style
diff --git a/tests/backend/specs/api/importexport/stylingWithFontAttributes.html b/tests/backend/specs/api/importexport/stylingWithFontAttributes.html
new file mode 100644
index 000000000..7ff607ca9
--- /dev/null
+++ b/tests/backend/specs/api/importexport/stylingWithFontAttributes.html
@@ -0,0 +1 @@
+line
bold strikethrough italic underline no style no style
diff --git a/tests/backend/specs/api/importexport/stylingWithSpanAndTagsWithoutAttributes.html b/tests/backend/specs/api/importexport/stylingWithSpanAndTagsWithoutAttributes.html
new file mode 100644
index 000000000..ee2c7dc60
--- /dev/null
+++ b/tests/backend/specs/api/importexport/stylingWithSpanAndTagsWithoutAttributes.html
@@ -0,0 +1 @@
+line
bold strikethrough italic underline no style no style
diff --git a/tests/backend/specs/api/importexport/stylingWithTagsWithoutAttributes.html b/tests/backend/specs/api/importexport/stylingWithTagsWithoutAttributes.html
new file mode 100644
index 000000000..c5a89343e
--- /dev/null
+++ b/tests/backend/specs/api/importexport/stylingWithTagsWithoutAttributes.html
@@ -0,0 +1 @@
+line
bold strikethrough italic underline no style no style
diff --git a/tests/backend/specs/api/importexport/testP.html b/tests/backend/specs/api/importexport/testP.html
new file mode 100644
index 000000000..6917177eb
--- /dev/null
+++ b/tests/backend/specs/api/importexport/testP.html
@@ -0,0 +1 @@
+
diff --git a/tests/backend/specs/api/importexport/ul.html b/tests/backend/specs/api/importexport/ul.html
new file mode 100644
index 000000000..01f32a2e1
--- /dev/null
+++ b/tests/backend/specs/api/importexport/ul.html
@@ -0,0 +1 @@
+div
foo
diff --git a/tests/backend/specs/api/importexport/ulIndented.html b/tests/backend/specs/api/importexport/ulIndented.html
new file mode 100644
index 000000000..fd5137697
--- /dev/null
+++ b/tests/backend/specs/api/importexport/ulIndented.html
@@ -0,0 +1 @@
+foo
diff --git a/tests/backend/specs/contentcollector.js b/tests/backend/specs/contentcollector.js
index 32faca66a..6e6b9b0b5 100644
--- a/tests/backend/specs/contentcollector.js
+++ b/tests/backend/specs/contentcollector.js
@@ -1,11 +1,19 @@
-const Changeset = require('../../../src/static/js/Changeset');
const contentcollector = require('../../../src/static/js/contentcollector');
const AttributePool = require('../../../src/static/js/AttributePool');
const cheerio = require('../../../src/node_modules/cheerio');
-const util = require('util');
+/**
+ * The html of these tests is intentionally collapsed into a single line, except in special cases.
+ * All tests are duplicated in ./tests/backend/specs/api/importexport/ where they are properly indented.
+ *
+ * While importexport tests target the `setHTML` API endpoint, which is nearly identical to what happens
+ * when a user manually imports a document via the UI, the contentcollector tests don't use rehype to process
+ * the document. Rehype remove spaces and newĺines were applicable.
+ *
+ * Note the final
in every of the tests except when the body ends in a list.
+ */
const tests = {
- nestedLi: {
+ nestedOrderedLi: {
description: 'Complex nested Li',
html: '- one
- 1.1
- two
',
expectedLineAttribs: [
@@ -89,7 +97,7 @@ const tests = {
expectedText: ['a', '*b', '*c', 'notlist', 'foo'],
noteToSelf: 'Ensure empty P does not induce line attribute marker, wont this break the editor?',
},
- nestedOl: {
+ nestedOl2: {
description: 'First item being an UL then subsequent being OL will fail',
html: '',
expectedLineAttribs: ['+1', '*0*1*2*3+1+1', '*0*4*2*5+1+1'],
@@ -105,8 +113,271 @@ const tests = {
noteToSelf: "should create a line break but not break numbering -- This is what I can't get working!",
disabled: true,
},
+ brDontBreakOL: {
+ description: 'A single completely empty line break using
within an ol should NOT reset count',
+ html: '- should be 1
- should be 2
- should be 3
',
+ expectedLineAttribs: [],
+ expectedText: ['*should be 1', '*should be 2', '*should be 3'],
+ disabled: true,
+ },
+ normalNewline: {
+ description: 'A normal newline as
should work',
+ html: 'line1
line2
',
+ expectedLineAttribs: ['+5','+5'],
+ expectedText: ['line1', 'line2'],
+ },
+ indents: {
+ disabled:true,
+ description: 'Two indentations',
+ html: '
',
+ expectedLineAttribs: ['*0*1*2+1+7', '*0*1*2+1+7', '*0*3*2+1+7', '*0*3*2+1+7'],
+ expectedText: ['*indent1', '*indent1', '*indent2', '*indent2', '*indent1']
+ },
+ indentsAndNewlines: {
+ disabled: true, // does which might not be right? instead:
+ description: 'Indentations and newlines',
+ html: '
',
+ expectedLineAttribs: ['*0*1*2+1+7', '', '*0*1*2+1+7', '*0*3*2+1+7', '', '*0*1*2+1+7', '*0*3*2+1+7'],
+ expectedText: ['*indent1', '', '*indent1', '*indent2', '', '*indent1', '*indent2']
+ },
+ multipleIndentLevelAndStyles: {
+ disabled:true,
+ description: '8 levels of indents, newlines and attributes',
+ html: '
indent4 line 2 bisuindent4 line 2 bs- indent4 line 2 u
uis
',
+ expectedLineAttribs: [],
+ expectedText: ['*indent line 1', '*indent line 1']
+ },
+ bulletsAndEmptyLines: {
+ disabled: true,
+ description: 'Bullet lists that contain empty lines',
+ html: '
',
+ expectedLineAttribs: [],
+ expectedText: ['*bullet line 1', '', '*bullet line 2', '', '*bullet2 line 1', '', '', '*bullet2 line 2', '']
+ },
+ indentsAndEmptyLines: {
+ disabled:true,
+ description: 'Indented lines that contain empty lines',
+ html: '
',
+ expectedLineAttribs: [],
+ expectedText: ['indented line 1', '', '', 'indented line 2', '', 'indent2 line 1']
+ },
+ bulletsAndNonBulletLines: {
+ disabled:true,
+ description: 'Bullet lists that contain not bullet lines',
+ html: 'not bullet',
+ expectedLineAttribs: [],
+ expectedText: []
+ },
+ indentsAndNonIndentedLines: {
+ disabled: true,
+ description: 'Indented lines that contain non indented lines',
+ html: 'not indent',
+ expectedLineAttribs: [],
+ expectedText: ['*indent line 1', 'not indent', 'not indent', '*indent line 2', '', '*indent2 line 1']
+ },
+ olWithNonDefaultStart: {
+ disabled: true,
+ description: 'An ordered list that does not start with 1',
+ html: '- 6
- 7
- 4
- 5
- 0.0.9
- 0.0.10
',
+ expectedLineAttribs: [
+ ],
+ expectedText: ['*6', '*7', '*4', '*5', '*0.0.9', '*0.0.10'] //0.0. is wrong
+//totally wrong after import
+/**
+1. 6
+1. 7
+2. 4
+3. 5
+ 3.0.1 0.0.9
+ 3.0.1 0.0.10
+
+only backwards key (and probably return key) trigger renumbering, it is not triggered when entering in any of the lines:
+1. 6
+2. 7
+3. 4
+4. 5
+ 4.0.1. 0.0.9
+ 4.0.2. 0.0.10
+*/
+ },
+ stylingWithAttributesAndTags: {
+ description: 'Styling applied as separate tags and span attributes',
+ html: 'line
bold strikethrough italic underline no style no style
',
+ expectedLineAttribs: ['+4', '*0*1*2*3+z+i'],
+ expectedText: ['line', 'bold strikethrough italic underline no style no style']
+ },
+ stylingWithSpanAndTagsWithoutAttributes: {
+ description: 'Styling applied as separate tags inside a span',
+ html: 'line
bold strikethrough italic underline no style no style
',
+ expectedLineAttribs: ['+4', '*0*1*2*3+z+i'],
+ expectedText: ['line', 'bold strikethrough italic underline no style no style']
+ },
+ stylingWithAttributesWithoutTags: {
+ disabled:true,
+ description: 'Styling applied as span attributes',
+ html: 'line
bold strikethrough italic underline no style no style
',
+ expectedLineAttribs: ['+4', '*0*1*2*3+z+i'],
+ expectedText: ['line', 'bold strikethrough italic underline no style no style']
+ },
+ stylingWithTagsWithoutAttributes: {
+ description: 'Styling applied as separate tags',
+ html: 'line
bold strikethrough italic underline no style no style
',
+ expectedLineAttribs: ['+4', '*0*1*2*3+z+i'],
+ expectedText: ['line', 'bold strikethrough italic underline no style no style']
+ },
+ stylingWithFontAttributes: {
+ disabled: true,
+ description: "Styling applied as font-style",
+ html: 'line
bold strikethrough italic underline no style no style',
+ expectedLineAttribs: [],
+ expectedText: ['abc']
+ },
+ dontDeleteSpaceInsideElements: { //BEGINNING AAND END
+ description: 'Preserve spaces on the beginning and end of a element',
+ html: 'Need more spaces !
',
+ expectedLineAttribs: ['+f*0+2+1'],
+ expectedText: ['Need more spaces !']
+ },
+ collapseSpacesInsideElements: {
+ description: 'Preserve only on space when multiple are present',
+ html: 'Need more space s !
',
+ expectedLineAttribs: ['+f*0'],
+ expectedText: ['Need more space s !'],
+ disabled: true
+ },
+ collapseSpacesAcrossNewlines: {
+ disabled:true,
+ description: 'Newlines and multiple spaces across newlines should be collapsed',
+ html: `
+ Need
+ more
+ space
+ s
+ !
`,
+ expectedLineAttribs: [],
+ expectedText: []
+ },
+ multipleNewLinesAtBeginning: {
+ disabled: true,
+ description: 'Multiple new lines at the beginning should be preserved',
+ html: '
first line
second line
',
+ expectedLineAttribs: [],
+ expectedText: []
+ },
+ spacesAfterNewline: {
+ description: 'Don\'t collapse spaces that follow a newline',
+ html: 'something
something
',
+ expectedLineAttribs: ['+9', '+m'],
+ expectedText: ['something', ' something']
+ },
+ spacesAfterNewlineP: {
+ description: 'Don\'t collapse spaces that follow a newline',
+ html: 'something something
',
+ expectedLineAttribs: ['+9', '', '+m'],
+ expectedText: ['something', '', ' something']
+ },
+ spacesAtEndOfLine: {
+ description: 'Don\'t collapse spaces that follow a newline',
+ html: 'something
something
',
+ expectedLineAttribs: ['+l', '+m'],
+ expectedText: ['something ', ' something']
+ },
+ spacesAtEndOfLineP: {
+ description: 'Don\'t collapse spaces that follow a newline',
+ html: 'something something
',
+ expectedLineAttribs: ['+l', '', '+m'],
+ expectedText: ['something ', '', ' something']
+ },
+ nonBreakingSpacesAfterNewlines: {
+ description: 'Don\'t collapse non-breaking spaces that follow a newline',
+ html: 'something
something
',
+ expectedLineAttribs: ['+9', '+c'],
+ expectedText: ['something', ' something']
+ },
+ nonBreakingSpacesAfterNewlinesP: {
+ description: 'Don\'t collapse non-breaking spaces that follow a newline',
+ html: 'something something
',
+ expectedLineAttribs: ['+9', '', '+c'],
+ expectedText: ['something', '', ' something']
+ },
+ ignoreAnyTagsOutsideBody: {
+ description: 'Never add non-breaking spaces for elements outside body',
+ html: 'titleempty
',
+ expectedLineAttribs: ['+5'],
+ expectedText: ['empty']
+ },
+ linebreakPreceedsOL: {
+ description: 'A break before an ordered list should not introduce a list item',
+ html: '
- should be 1
',
+ //expectedHTML: '
- should be 1
',
+ expectedLineAttribs: ['', '*0*1*2*3+1+b'],
+ //expectedText: '\n\t1. should be 1\n\n'
+ expectedText: ['', '*should be 1']
+ },
+ paragraphPreceedsOL:{
+ description: 'An empty paragraph before an ordered list should not introduce a list item',
+ html: '- should be 1
',
+ //expectedHTML: '
- should be 1
',
+ //expectedText: '\n\t1. should be 1\n\n'
+ expectedLineAttribs: ['', '*0*1*2*3+1+b'],
+ expectedText: ['', '*should be 1']
+ },
+ lineWithSpacesPreceedsOL:{
+ disabled:true,
+ description: 'A single line with a space right before an ordered list should not introduce a list item',
+ html: '
- should be 1
',
+ expectedLineAttribs: ['', '*0*1*2*3+1+b'],
+ expectedText: ['', '', ' ', '*should be 1']
+ //expectedHTML: '
- should be 1
',
+ //expectedText: '\n\n\n\t1. should be 1\n\n'
+ },
+ multipleParagraphsWithSpacesPreceedsOL: {
+ description: 'Paragraphs with spaces right before an ordered list should not introduce a list item',
+ html: '
- should be 1
',
+ expectedLineAttribs: ['+1', '+1', '+1', '*0*1*2*3+1+b'],
+ expectedText: [' ', ' ', ' ', '*should be 1']
+ //expectedHTML: '
- should be 1
',
+ //expectedText: '\n\n\n\t1. should be 1\n\n'
+ },
+ multiLineParagraph:{
+ description: "A paragraph with multiple lines should not loose spaces when lines are combined",
+ html: `
+а б в г ґ д е є ж з и і ї й к л м н о
+п р с т у ф х ц ч ш щ ю я ь
+`,
+ expectedLineAttribs: [ '+1t' ],
+ expectedText: ["а б в г ґ д е є ж з и і ї й к л м н о п р с т у ф х ц ч ш щ ю я ь"]
+ },
+ multiLineParagraphWithPre:{
+ description: "lines in preformatted text should be kept intact",
+ html: `
+а б в г ґ д е є ж з и і ї й к л м н о
multiple
+lines
+in
+pre
+
п р с т у ф х ц ч ш щ ю я
+ь
+`,
+ expectedLineAttribs: [ '+11', '+8', '+5', '+2', '+3', '+r' ],
+ expectedText: ['а б в г ґ д е є ж з и і ї й к л м н о', 'multiple', 'lines', 'in', 'pre', 'п р с т у ф х ц ч ш щ ю я ь']
+ },
+ preIntroducesASpace: {
+ description: "pre should be on a new line not preceeded by a space",
+ html: `
+ 1
+
preline
+
`,
+ expectedLineAttribs: [ '+6', '+7' ],
+ expectedText: [' 1 ', 'preline']
+ },
+ linesWithMoreThanOnceSpace: {
+ description: 'Multiple spaces should be preserved',
+ html: 'Text with more than one space.
',
+ expectedLineAttribs: [ '+10' ],
+ expectedText: ['Text with more than one space.']
+ }
+}
-};
describe(__filename, function () {
for (const test in tests) {
@@ -120,7 +391,7 @@ describe(__filename, function () {
it(testObj.description, function (done) {
const $ = cheerio.load(testObj.html); // Load HTML into Cheerio
- const doc = $('html')[0]; // Creates a dom-like representation of HTML
+ const doc = $('body')[0]; // Creates a dom-like representation of HTML
// Create an empty attribute pool
const apool = new AttributePool();
// Convert a dom tree into a list of lines and attribute liens
@@ -130,6 +401,8 @@ describe(__filename, function () {
const result = cc.finish();
const recievedAttributes = result.lineAttribs;
const expectedAttributes = testObj.expectedLineAttribs;
+// console.warn(result)
+// console.warn("the pool:",apool)
const recievedText = new Array(result.lines);
const expectedText = testObj.expectedText;