Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MIME Normalizer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
JS Toolbox
MIME Normalizer
Commits
ea889efc
Commit
ea889efc
authored
4 years ago
by
Igor Markin
Browse files
Options
Downloads
Patches
Plain Diff
Add pseudoplain tests
parent
b26ccc5e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!6
Implement pseudo plain parsing
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
__tests__/pseudoplain-outlook-outlook.test.ts
+97
-0
97 additions, 0 deletions
__tests__/pseudoplain-outlook-outlook.test.ts
__tests__/utils.ts
+22
-0
22 additions, 0 deletions
__tests__/utils.ts
package.json
+1
-0
1 addition, 0 deletions
package.json
with
120 additions
and
0 deletions
__tests__/pseudoplain-outlook-outlook.test.ts
0 → 100644
+
97
−
0
View file @
ea889efc
import
{
diffStringsUnified
}
from
"
jest-diff
"
;
import
{
describe
,
test
}
from
"
@jest/globals
"
;
import
{
getDOMDocuments
,
getTestCasesDirs
}
from
"
./utils
"
;
const
path
=
require
(
"
path
"
);
const
TESTS_GLOBAL_PATH
=
"
/files/outlook-outlook
"
;
const
testsPath
=
path
.
resolve
(
__dirname
,
`.
${
TESTS_GLOBAL_PATH
}
`
);
const
createDescribePseudoPlainTestCases
=
(
testsPath
:
string
)
=>
/**
* @param casesGroupName - name of the folder with cases
* @param failingCases - a list of cases that are failing and ignored. Pending to be fixed
* @param casesToCheckOnly - a filter to use if you want to check specific cases
*/
(
casesGroupName
:
string
,
failingCases
?:
Array
<
string
>
,
casesToCheckOnly
?:
Array
<
string
>
)
=>
():
void
=>
{
const
testsCasesPath
=
testsPath
+
"
/
"
+
casesGroupName
;
let
testCasesDirs
=
getTestCasesDirs
(
testsCasesPath
);
if
(
casesToCheckOnly
&&
casesToCheckOnly
.
length
)
{
testCasesDirs
=
testCasesDirs
.
filter
((
dir
)
=>
casesToCheckOnly
.
includes
(
dir
)
);
}
if
(
failingCases
&&
failingCases
.
length
)
{
testCasesDirs
=
testCasesDirs
.
filter
(
(
dir
)
=>
!
failingCases
.
includes
(
dir
)
);
}
test
.
each
(
testCasesDirs
)(
"
Case %s
"
,
(
dirName
:
string
)
=>
{
const
testCasePath
=
testsCasesPath
+
"
/
"
+
dirName
;
const
{
sentHtmlDocument
,
receivedHtmlDocument
}
=
getDOMDocuments
(
testCasePath
);
const
difference
=
diffStringsUnified
(
receivedHtmlDocument
.
body
.
textContent
,
sentHtmlDocument
.
body
.
textContent
);
console
.
log
(
difference
);
});
};
describe
(
"
[Pseudo PLAIN] Outlook-Outlook normalization
"
,
()
=>
{
const
describeFunction
=
createDescribePseudoPlainTestCases
(
testsPath
);
// ["01"] - is a filter. Pass here names of directories with test cases you want to check
describe
(
"
Emails Chrome
"
,
describeFunction
(
"
chrome
"
,
null
,
[
"
01
"
]));
// describe(
// "Emails Edge",
// describeFunction("edge", [
// "21", // This case has a src mismatch for the same image. Reproduce this case again
// "08", // Files are missing for test case
// "10", // Files are missing for test case
// ])
// );
// describe(
// "Emails Safari",
// describeFunction("safari", [
// "04", // This case contains <section> tag which is ignored by Outlook, and it also inserts a plenty of empty divs,
// "08",
// ])
// );
// Does not work at all
// describe(
// "Emails MacOS",
// describeFunction("macos", ["20", "21", "", "23", "24", "25", "26"])
// );
// describe(
// "Emails Windows",
// describeFunction("windows", [
// "06",
// "20",
// "20forward",
// "20reply",
// "21",
// "21forward",
// "21reply",
// "22",
// "23",
// "24",
// "25",
// "26",
// "28",
// "10", // missing files
// ])
// );
});
This diff is collapsed.
Click to expand it.
__tests__/utils.ts
+
22
−
0
View file @
ea889efc
...
...
@@ -129,3 +129,25 @@ export const createDescribePlainTestCases = (testsPath: string) => (
expect
(
receivedPlain
).
toContain
(
sentPlain
);
});
};
export
const
getDOMDocuments
=
(
testCasePath
:
string
):
{
sentHtmlDocument
:
HTMLDocument
;
receivedHtmlDocument
:
HTMLDocument
;
}
=>
{
const
sentHtml
=
fs
.
readFileSync
(
`
${
testCasePath
}
/
${
SENT_HTML_NAME
}
`
)
.
toString
();
const
receivedHtml
=
fs
.
readFileSync
(
`
${
testCasePath
}
/
${
RECEIVED_HTML_NAME
}
`
)
.
toString
();
const
sentDOM
=
new
JSDOM
(
sentHtml
);
const
receivedDOM
=
new
JSDOM
(
receivedHtml
);
return
{
sentHtmlDocument
:
sentDOM
.
window
.
document
,
receivedHtmlDocument
:
receivedDOM
.
window
.
document
,
};
};
This diff is collapsed.
Click to expand it.
package.json
+
1
−
0
View file @
ea889efc
...
...
@@ -18,6 +18,7 @@
"
eslint
"
:
"
^7.7.0
"
,
"
husky
"
:
"
^4.2.5
"
,
"
jest
"
:
"
^26.4.2
"
,
"
jest-diff
"
:
"
^26.6.2
"
,
"
lint-staged
"
:
"
^10.2.13
"
,
"
prettier
"
:
"
^2.1.1
"
,
"
typescript
"
:
"
^4.0.2
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment