mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 23:58:07 +02:00
Merge pull request #12349 from calixteman/followup_12344
Follow-up of pr #12344
This commit is contained in:
commit
f9d56320f5
9 changed files with 69 additions and 56 deletions
|
@ -18,6 +18,7 @@ import {
|
|||
getInheritableProperty,
|
||||
isWhiteSpace,
|
||||
log2,
|
||||
parseXFAPath,
|
||||
toRomanNumerals,
|
||||
} from "../../src/core/core_utils.js";
|
||||
import { XRefMock } from "./test_utils.js";
|
||||
|
@ -211,4 +212,18 @@ describe("core_utils", function () {
|
|||
expect(isWhiteSpace(undefined)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseXFAPath", function () {
|
||||
it("should get a correctly parsed path", function () {
|
||||
const path = "foo.bar[12].oof[3].rab.FOO[123].BAR[456]";
|
||||
expect(parseXFAPath(path)).toEqual([
|
||||
{ name: "foo", pos: 0 },
|
||||
{ name: "bar", pos: 12 },
|
||||
{ name: "oof", pos: 3 },
|
||||
{ name: "rab", pos: 0 },
|
||||
{ name: "FOO", pos: 123 },
|
||||
{ name: "BAR", pos: 456 },
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,7 +25,6 @@ import {
|
|||
isNum,
|
||||
isSameOrigin,
|
||||
isString,
|
||||
parseXFAPath,
|
||||
removeNullCharacters,
|
||||
string32,
|
||||
stringToBytes,
|
||||
|
@ -334,20 +333,6 @@ describe("util", function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe("parseXFAPath", function () {
|
||||
it("should get a correctly parsed path", function () {
|
||||
const path = "foo.bar[12].oof[3].rab.FOO[123].BAR[456]";
|
||||
expect(parseXFAPath(path)).toEqual([
|
||||
{ name: "foo", pos: 0 },
|
||||
{ name: "bar", pos: 12 },
|
||||
{ name: "oof", pos: 3 },
|
||||
{ name: "rab", pos: 0 },
|
||||
{ name: "FOO", pos: 123 },
|
||||
{ name: "BAR", pos: 456 },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("encodeToXmlString", function () {
|
||||
it("should get a correctly encoded string with some entities", function () {
|
||||
const str = "\"\u0397ell😂' & <W😂rld>";
|
||||
|
|
|
@ -37,7 +37,7 @@ describe("Writer", function () {
|
|||
info: {},
|
||||
};
|
||||
|
||||
let data = incrementalUpdate(originalData, xrefInfo, newRefs, null, null);
|
||||
let data = incrementalUpdate({ originalData, xrefInfo, newRefs });
|
||||
data = bytesToString(data);
|
||||
|
||||
const expected =
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { parseXFAPath } from "../../src/shared/util.js";
|
||||
import { parseXFAPath } from "../../src/core/core_utils.js";
|
||||
import { SimpleXMLParser } from "../../src/shared/xml_parser.js";
|
||||
|
||||
describe("XML", function () {
|
||||
|
@ -69,7 +69,7 @@ describe("XML", function () {
|
|||
});
|
||||
|
||||
it("should dump a xml tree", function () {
|
||||
let xml = `
|
||||
const xml = `
|
||||
<a>
|
||||
<b>
|
||||
<c a="123"/>
|
||||
|
@ -87,9 +87,7 @@ describe("XML", function () {
|
|||
<h>
|
||||
<i/>
|
||||
<j/>
|
||||
<k>
|
||||
W😂rld
|
||||
<g a="654"/>
|
||||
<k>
W😂rld
<g a="654"/>
|
||||
</k>
|
||||
</h>
|
||||
<b>
|
||||
|
@ -98,13 +96,14 @@ describe("XML", function () {
|
|||
<g a="121110"/>
|
||||
</b>
|
||||
</a>`;
|
||||
xml = xml.replace(/\s+/g, "");
|
||||
const root = new SimpleXMLParser(true).parseFromString(xml)
|
||||
.documentElement;
|
||||
const buffer = [];
|
||||
root.dump(buffer);
|
||||
|
||||
expect(buffer.join("").replace(/\s+/g, "")).toEqual(xml);
|
||||
expect(buffer.join("").replace(/\s+/g, "")).toEqual(
|
||||
xml.replace(/\s+/g, "")
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue