import { JSDOM } from 'jsdom'
import { findLink, findTag, findAccount } from '@/utils/tootParser'
describe('findLink', () => {
describe('Pleroma', () => {
const doc = new JSDOM(`
`).window.document
const target = doc.getElementById('link')
it('should find', () => {
const res = findLink(target)
expect(res).toEqual('https://github.com/h3poteto/whalebird-desktop/releases/tag/2.4.1')
})
})
})
describe('findTag', () => {
describe('Pleroma', () => {
const doc = new JSDOM(`
`).window.document
const target = doc.getElementById('tag')
it('should find', () => {
expect(target).not.toBeNull()
const res = findTag(target!)
expect(res).toEqual('whalebird')
})
})
describe('Mastodon', () => {
const doc = new JSDOM(`
`).window.document
const target = doc.getElementById('tag')
it('should find', () => {
expect(target).not.toBeNull()
const res = findTag(target!)
expect(res).toEqual('whalebird')
})
})
})
describe('findAccount', () => {
describe('in Pleroma', () => {
describe('from Mastodon', () => {
const doc = new JSDOM(`
`).window.document
const target = doc.getElementById('user')
it('should find', () => {
expect(target).not.toBeNull()
const res = findAccount(target!)
expect(res).not.toBeNull()
expect(res!.username).toEqual('@h3_poteto')
expect(res!.acct).toEqual('@h3_poteto@social.mikutter.hachune.net')
})
})
describe('from Pleroma', () => {
const doc = new JSDOM(`
`).window.document
const target = doc.getElementById('user')
it('should find', () => {
expect(target).not.toBeNull()
const res = findAccount(target!)
expect(res).not.toBeNull()
expect(res!.username).toEqual('@h3poteto')
expect(res!.acct).toEqual('@h3poteto@pleroma.io')
})
})
describe('toot link in Mastodon', () => {
const doc = new JSDOM(`
`).window.document
const target = doc.getElementById('status')
it('should not find', () => {
expect(target).not.toBeNull()
const res = findAccount(target!)
expect(res).toBeNull()
})
})
describe('toot link in Pleroma', () => {
const doc = new JSDOM(`
`).window.document
const target = doc.getElementById('status')
it('should not find', () => {
expect(target).not.toBeNull()
const res = findAccount(target!)
expect(res).toBeNull()
})
})
})
})