mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-01 02:17:53 +01:00
Feature/add unit testing framework and start writing unit tests (acceptance tests) (#708)
* add jest and rewire for testing * wrap loose code for initMutationObserver() in function and call it instead of just executing it Otherwise this code is executed everytime state.js is imported somewhere in a file. This leads to not being able to test properly, since state.js is imported in a lot of the src files and fails when running the tests since we are missing global environment settings such as document, window etc in the jest environment. * export roundDown and getNumberformatter to make them testable as well * add basic acceptance tests for utils.js, create snapshots and add jest config * add failing test for buggy behaviour in a separate test case and skip it until fixed * Fixes after merge conflicts --------- Co-authored-by: Dmitrii Selivanov <selivano.d@gmail.com>
This commit is contained in:
1 parent
fbf00e474d
commit
d62130b898
9 files changed
+400
-8134
No files matched your search
@@ -66,7 +66,8 @@ function getVideoId(url) {
|
||||
const urlObject = new URL(url);
|
||||
const pathname = urlObject.pathname;
|
||||
if (pathname.startsWith("/clip")) {
|
||||
return (document.querySelector("meta[itemprop='videoId']") || document.querySelector("meta[itemprop='identifier']")).content;
|
||||
return (document.querySelector("meta[itemprop='videoId']") || document.querySelector("meta[itemprop='identifier']"))
|
||||
.content;
|
||||
} else {
|
||||
if (pathname.startsWith("/shorts")) {
|
||||
return pathname.slice(8);
|
||||
@@ -103,7 +104,7 @@ function isVideoLoaded() {
|
||||
}
|
||||
|
||||
function cLog(message, writer) {
|
||||
if (!extConfig.disableLogging){
|
||||
if (!extConfig.disableLogging) {
|
||||
message = `[return youtube dislike]: ${message}`;
|
||||
if (writer) {
|
||||
writer(message);
|
||||
@@ -177,6 +178,7 @@ function createObserver(options, callback) {
|
||||
|
||||
export {
|
||||
numberFormat,
|
||||
getNumberFormatter,
|
||||
getBrowser,
|
||||
getVideoId,
|
||||
isInViewport,
|
||||
|
||||
Reference in new issue
Block a user