Skip to content
Snippets Groups Projects
Commit efc1a746 authored by Igor Markin's avatar Igor Markin
Browse files

Upgrades lib-mime, uses JSDOM instead of @vereign/dom

parent 9a587685
No related branches found
No related tags found
1 merge request!25Resolve "Upgrade light-utils and lib-mime"
Pipeline #42697 failed
import { JSDOM } from "jsdom"; import { JSDOM } from "jsdom";
const crypto = require("crypto"); const crypto = require("crypto");
import MIMEParser from "@vereign/mime-parser"; import MIMEParser from "@vereign/lib-mime";
import { expect, test } from "@jest/globals"; import { expect, test } from "@jest/globals";
import { DOM } from "@vereign/dom";
import { PlainNormalizer, HTMLNormalizer } from "../../src"; import { PlainNormalizer, HTMLNormalizer } from "../../src";
import { listDirectories, readFile } from "./fileReader"; import { listDirectories, readFile } from "./fileReader";
...@@ -207,11 +206,21 @@ const prepareTestCases = ( ...@@ -207,11 +206,21 @@ const prepareTestCases = (
`${testsCasesPath}/${caseDir}/${RECEIVED_EML_NAME}` `${testsCasesPath}/${caseDir}/${RECEIVED_EML_NAME}`
); );
const sentParsedMime = new MIMEParser(sentMimeString);
sentParsedMime.parseHTML = (htmlString: string) => {
return new JSDOM(htmlString).window.document;
};
const receivedParsedMime = new MIMEParser(receivedMimeString);
receivedParsedMime.parseHTML = (htmlString: string) => {
return new JSDOM(htmlString).window.document;
};
return [ return [
caseDir, caseDir,
{ {
sentMime: new MIMEParser(sentMimeString), sentMime: sentParsedMime,
receivedMime: new MIMEParser(receivedMimeString), receivedMime: receivedParsedMime,
}, },
]; ];
}); });
...@@ -249,10 +258,7 @@ export const getDOMDocuments = async ( ...@@ -249,10 +258,7 @@ export const getDOMDocuments = async (
sentHtmlDocument: HTMLDocument; sentHtmlDocument: HTMLDocument;
receivedHtmlDocument: HTMLDocument; receivedHtmlDocument: HTMLDocument;
}> => { }> => {
/** const sentDOM = new JSDOM(
* Usage of the @vereign/dom is a must, because of Google Add-on.
*/
const sentDOM = new DOM(
await sentMime.getHTML({ await sentMime.getHTML({
populateAttachments: POPULATE_ATTACHMENTS, populateAttachments: POPULATE_ATTACHMENTS,
hashAttachment, hashAttachment,
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment