Provide error page for age gated profiles
This commit is contained in:
21
test/body.js
21
test/body.js
@@ -4,16 +4,27 @@ const {extractSharedData} = require("../src/lib/utils/body")
|
||||
const fs = require("fs").promises
|
||||
|
||||
tap.test("extract shared data", async childTest => {
|
||||
childTest.throws(() => extractSharedData(""), constants.symbols.NO_SHARED_DATA, "not found in blank")
|
||||
{
|
||||
const result = extractSharedData("")
|
||||
childTest.equal(result.status, constants.symbols.extractor_results.NO_SHARED_DATA, "not found in blank")
|
||||
}
|
||||
{
|
||||
const page = await fs.readFile("test/files/page-user-instagram.html", "utf8")
|
||||
const sharedData = extractSharedData(page)
|
||||
childTest.equal(sharedData.entry_data.ProfilePage[0].graphql.user.username, "instagram", "can extract user page")
|
||||
const result = extractSharedData(page)
|
||||
childTest.equal(result.status, constants.symbols.extractor_results.SUCCESS, "extractor status success")
|
||||
childTest.equal(result.value.entry_data.ProfilePage[0].graphql.user.username, "instagram", "can extract user page")
|
||||
}
|
||||
{
|
||||
const page = await fs.readFile("test/files/page-login.html", "utf8")
|
||||
const sharedData = extractSharedData(page)
|
||||
childTest.true(sharedData.entry_data.LoginAndSignupPage[0], "can extract login page")
|
||||
const result = extractSharedData(page)
|
||||
childTest.equal(result.status, constants.symbols.extractor_results.SUCCESS, "extractor status success")
|
||||
childTest.true(result.value.entry_data.LoginAndSignupPage[0], "can extract login page")
|
||||
}
|
||||
{
|
||||
const page = await fs.readFile("test/files/page-age-gated.html", "utf8")
|
||||
const result = extractSharedData(page)
|
||||
childTest.equal(result.status, constants.symbols.extractor_results.AGE_RESTRICTED, "extractor detects age restricted")
|
||||
childTest.equal(result.value, 21, "correct age is extracted")
|
||||
}
|
||||
childTest.end()
|
||||
})
|
||||
|
||||
321
test/files/page-age-gated.html
Normal file
321
test/files/page-age-gated.html
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user