Skip to content

Commit 81a0ee8

Browse files
committed
fix: use DOMParser from browser (and mock it in tests)
1 parent 71d61c9 commit 81a0ee8

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

scripts/import_and_patch_translators.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"requestJSON",
2828
"requestText",
2929
"attr",
30-
"DOMParser",
3130
]
3231
FW_LINE_PREFIX = "/* FW LINE 59:b820c6d */"
3332
TRANSLATOR_EXPORT_CANDIDATES = [

tests/translator-import.test.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ const EXPORT_CANDIDATES = [
1717
"doExport",
1818
];
1919

20+
// DOMParser is provided by the browser environment
21+
// So we mock it here
22+
globalThis.DOMParser = class {
23+
parseFromString() {
24+
return {};
25+
}
26+
};
27+
2028
setSandbox({
2129
ZU: {
2230
cleanAuthor: (_) => {},
@@ -29,11 +37,6 @@ setSandbox({
2937
requestText: async () => {},
3038
text: () => "",
3139
attr: () => "",
32-
DOMParser: class {
33-
parseFromString() {
34-
return {};
35-
}
36-
},
3740
});
3841

3942
describe("Zotero translator", () => {

0 commit comments

Comments
 (0)