fp/packages/scout/src/parsers.spec.js

34 lines
1.8 KiB
JavaScript

'use strict'
import { expect } from 'chai'
import { checkEmail } from './parsers.js'
import fs from 'node:fs/promises'
import path from 'node:path'
const __dirname = import.meta.dirname;
describe('parsers', function () {
describe('checkEmail', function () {
it('should detect fansly e-mails and return channel data', async function () {
const mailBody = await fs.readFile(path.join(__dirname, './fixtures/fansly.fixture.txt'), { encoding: 'utf8' })
const { isMatch, channel, platform, url, date, userId, avatar } = await checkEmail(mailBody)
expect(isMatch).to.equal(true, 'a Fansly heuristic was not found')
expect(platform).to.equal('fansly')
expect(channel).to.equal('SkiaObsidian')
expect(url).to.equal('https://fansly.com/SkiaObsidian')
expect(date).to.equal('2024-05-05T03:04:33.000Z')
expect(userId).to.equal('555722198917066752')
expect(avatar).to.equal('https://api.fansly.com/api/v1/account/555722198917066752/avatar')
})
it('should detect cb e-mails and return channel data', async function () {
const mailBody = await fs.readFile(path.join(__dirname, './fixtures/chaturbate.fixture.txt'), { encoding: 'utf8' })
const { isMatch, channel, platform, url, date, userId, avatar } = await checkEmail(mailBody)
expect(isMatch).to.equal(true, 'a CB heuristic was not found')
expect(platform).to.equal('chaturbate')
expect(channel).to.equal('skyeanette')
expect(url).to.equal('https://chaturbate.com/skyeanette')
expect(date).to.equal('2023-07-24T01:08:28.000Z')
expect(userId).to.equal(null) // this info is not in the CB e-mail
expect(avatar).to.equal(null)
})
})
})