aboutsummaryrefslogtreecommitdiff
path: root/test/docx
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-05-28 20:03:21 +0100
committerMichael Williamson <mike@zwobble.org>2025-05-28 20:03:21 +0100
commitff3cfe7892c591a9c3bb79335b9571f9f4a1b4b0 (patch)
treee300da85c3b3d7ee971719cb6c9734860840b203 /test/docx
parent5896154e69430a67a758864576c5eda8796f152a (diff)
Handle AlternateContent without Fallback in office-xml-reader
Diffstat (limited to 'test/docx')
-rw-r--r--test/docx/office-xml-reader.tests.js49
1 files changed, 33 insertions, 16 deletions
diff --git a/test/docx/office-xml-reader.tests.js b/test/docx/office-xml-reader.tests.js
index 9a053bc..a017315 100644
--- a/test/docx/office-xml-reader.tests.js
+++ b/test/docx/office-xml-reader.tests.js
@@ -5,20 +5,37 @@ var officeXmlReader = require("../../lib/docx/office-xml-reader");
var test = require("../test")(module);
-test("mc:AlternateContent is replaced by contents of mc:Fallback", function() {
- var xmlString =
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
- '<numbering xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">' +
- '<mc:AlternateContent>' +
- '<mc:Choice Requires="w14">' +
- '<choice/>' +
- '</mc:Choice>' +
- '<mc:Fallback>' +
- '<fallback/>' +
- '</mc:Fallback>' +
- '</mc:AlternateContent>' +
- '</numbering>';
- return officeXmlReader.read(xmlString).then(function(element) {
- assert.deepEqual(element.children, [xml.element("fallback")]);
- });
+test("mc:AlternateContent", {
+ "when mc:Fallback is present then mc:Fallback is read": function() {
+ var xmlString =
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
+ '<numbering xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">' +
+ '<mc:AlternateContent>' +
+ '<mc:Choice Requires="w14">' +
+ '<choice/>' +
+ '</mc:Choice>' +
+ '<mc:Fallback>' +
+ '<fallback/>' +
+ '</mc:Fallback>' +
+ '</mc:AlternateContent>' +
+ '</numbering>';
+ return officeXmlReader.read(xmlString).then(function(element) {
+ assert.deepEqual(element.children, [xml.element("fallback")]);
+ });
+ },
+
+ "when mc:Fallback is not present then element is ignored": function() {
+ var xmlString =
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
+ '<numbering xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">' +
+ '<mc:AlternateContent>' +
+ '<mc:Choice Requires="w14">' +
+ '<choice/>' +
+ '</mc:Choice>' +
+ '</mc:AlternateContent>' +
+ '</numbering>';
+ return officeXmlReader.read(xmlString).then(function(element) {
+ assert.deepEqual(element.children, []);
+ });
+ }
});