Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylicium committed Aug 10, 2023
1 parent efc88ea commit 54a93d0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
8 changes: 6 additions & 2 deletions __tests__/dev-ztParser.tests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@



const somef = require("../localModules/someFunctions")
const ZTP = require("../localModules/dev-ztParser")
ZTP._setAxiosRequestTimeInBetween(400)
ZTP._setDevMode(false)
Expand Down Expand Up @@ -55,7 +58,7 @@ for(let i in categories) {

for(let i in testedMovies) {

let s1 = await ZTP.search("films",testedMovies[i])
let s1 = (await ZTP.search("films",testedMovies[i]))[0]

/* object.title */
expect(s1.title).not.toBeUndefined()
Expand Down Expand Up @@ -93,7 +96,8 @@ for(let i in categories) {
'HDLIGHT',
'4K',
'WEBRIP',
'HDRIP'
'HDRIP',
'DVDRIP'
]
expect(somef.anyWordInText(s1.quality, all_quality, false)).toBe(true)

Expand Down
8 changes: 6 additions & 2 deletions __tests__/ztParser.tests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@



const somef = require("../localModules/someFunctions")
const ZTP = require("../localModules/ztParser")
ZTP._setAxiosRequestTimeInBetween(400)
ZTP._setDevMode(false)
Expand Down Expand Up @@ -55,7 +58,7 @@ for(let i in categories) {

for(let i in testedMovies) {

let s1 = await ZTP.search("films",testedMovies[i])
let s1 = (await ZTP.search("films",testedMovies[i]))[0]

/* object.title */
expect(s1.title).not.toBeUndefined()
Expand Down Expand Up @@ -93,7 +96,8 @@ for(let i in categories) {
'HDLIGHT',
'4K',
'WEBRIP',
'HDRIP'
'HDRIP',
'DVDRIP'
]
expect(somef.anyWordInText(s1.quality, all_quality, false)).toBe(true)

Expand Down
30 changes: 20 additions & 10 deletions localModules/dev-ztParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,32 @@ class ZoneTelechargementParser {
return x.getAttribute("class") == "cover_infos_title"
})[0].getElementsByTagName("a")[0].getAttribute("href")

// if(this._devMode) console.log("\n\nDOM: ", [...elem.getElementsByTagName("div")].map(x => x.innerHTML),"\n\n");

let detail_release = [...elem.getElementsByClassName("cover_infos_global")]
.map(x => {
const matches = x.innerHTML.match(/<b>(.*?)<\/b>/g);
if (matches) {
return matches.map(match => match.match(/<b>(.*?)<\/b>/)[1]);
}
return [];
}).reduce((acc, values) => acc.concat(values), []);

// if(this._devMode) console.log("detail_release: ", detail_release)

let publishDate = new Date(elem.getElementsByTagName("time")[0].textContent)

let movieDatas = {
"title": [...elem.getElementsByTagName("div")].filter(x => {
return x.getAttribute("class") == "cover_infos_title"
})[0].getElementsByTagName("a")[0].textContent,
"url": the_url,
"id": the_url.match(/[?&]id=[0-9]{1,5}\-/gmi)[0].match(/\d+/)[0],
"image": this._getBaseURL() + [...elem.getElementsByTagName("img")].filter(x => {
return x.getAttribute("class") == "mainimg"
})[0].src,
"quality": [...movieList_elements[2].getElementsByTagName("div")].filter(x => {
return x.getAttribute("class") == "cover_infos_title"
})[0].getElementsByClassName("detail_release")[0].getElementsByTagName("b")[0].textContent,
"language": this._getMatchingGroups([...movieList_elements[2].getElementsByTagName("div")].filter(x => {
return x.getAttribute("class") == "cover_infos_title"
})[0].getElementsByClassName("detail_release")[0].getElementsByTagName("b")[1].textContent)[0],
"publishedOn": new Date(elem.getElementsByTagName("time")[0].textContent)
"image": this._getBaseURL() + [...elem.getElementsByTagName("img")].map(x => x.getAttribute("src"))[0],
"quality": detail_release[0],
"language": detail_release[1].slice(1, -1),
"publishedOn": publishDate,
"publishedTimestamp": publishDate.getTime(),
}
responseMovieList.push(movieDatas)
}
Expand Down

0 comments on commit 54a93d0

Please sign in to comment.