mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fix tests
This commit is contained in:
parent
60bbbb6cf3
commit
1b8850ed33
6 changed files with 33 additions and 24 deletions
|
|
@ -409,8 +409,8 @@ export const parseUrlMetadata = async (
|
|||
// as a utility method on each one.
|
||||
export const isProbablyNewsletter = (html: string): boolean => {
|
||||
const dom = parseHTML(html).document
|
||||
const domCopy = parseHTML(dom.documentElement.outerHTML)
|
||||
const article = new Readability(domCopy.document, {
|
||||
const domCopy = parseHTML(dom.documentElement.outerHTML).document
|
||||
const article = new Readability(domCopy, {
|
||||
debug: false,
|
||||
keepTables: true,
|
||||
}).parse()
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import { getPageByParam } from '../../src/elastic/pages'
|
|||
|
||||
describe('saveEmail', () => {
|
||||
const username = 'fakeUser'
|
||||
const fakeContent = 'fake content'
|
||||
|
||||
after(async () => {
|
||||
await deleteTestUser(username)
|
||||
})
|
||||
|
|
@ -21,7 +23,7 @@ describe('saveEmail', () => {
|
|||
}
|
||||
|
||||
await saveEmail(ctx, {
|
||||
originalContent: 'fake content',
|
||||
originalContent: `<html><body>${fakeContent}</body></html>`,
|
||||
url: 'https://example.com',
|
||||
title: 'fake title',
|
||||
author: 'fake author',
|
||||
|
|
@ -30,7 +32,7 @@ describe('saveEmail', () => {
|
|||
// This ensures row level security doesnt prevent
|
||||
// resaving the same URL
|
||||
const secondResult = await saveEmail(ctx, {
|
||||
originalContent: 'fake content',
|
||||
originalContent: `<html><body>${fakeContent}</body></html>`,
|
||||
url: 'https://example.com',
|
||||
title: 'fake title',
|
||||
author: 'fake author',
|
||||
|
|
@ -42,6 +44,6 @@ describe('saveEmail', () => {
|
|||
expect(page?.url).to.equal('https://example.com')
|
||||
expect(page?.title).to.equal('fake title')
|
||||
expect(page?.author).to.equal('fake author')
|
||||
expect(page?.content).to.contain('fake content')
|
||||
expect(page?.content).to.contain(fakeContent)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { getPageByParam } from '../../src/elastic/pages'
|
|||
|
||||
describe('saveNewsletterEmail', () => {
|
||||
const username = 'fakeUser'
|
||||
const fakeContent = 'fake content'
|
||||
|
||||
let user: User
|
||||
let email: NewsletterEmail
|
||||
|
|
@ -32,13 +33,16 @@ describe('saveNewsletterEmail', () => {
|
|||
})
|
||||
|
||||
it('adds the newsletter to the library', async () => {
|
||||
await saveNewsletterEmail({
|
||||
email: email.address,
|
||||
content: 'fake content',
|
||||
url: 'https://example.com',
|
||||
title: 'fake title',
|
||||
author: 'fake author',
|
||||
}, ctx)
|
||||
await saveNewsletterEmail(
|
||||
{
|
||||
email: email.address,
|
||||
content: `<html><body>${fakeContent}</body></html>`,
|
||||
url: 'https://example.com',
|
||||
title: 'fake title',
|
||||
author: 'fake author',
|
||||
},
|
||||
ctx
|
||||
)
|
||||
|
||||
setTimeout(async () => {
|
||||
const page = await getPageByParam({ userId: user.id })
|
||||
|
|
@ -48,7 +52,7 @@ describe('saveNewsletterEmail', () => {
|
|||
expect(page.url).to.equal('https://example.com')
|
||||
expect(page.title).to.equal('fake title')
|
||||
expect(page.author).to.equal('fake author')
|
||||
expect(page.content).to.contain('fake content')
|
||||
expect(page.content).to.contain(fakeContent)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -58,13 +62,16 @@ describe('saveNewsletterEmail', () => {
|
|||
color: '#07D2D1',
|
||||
}
|
||||
|
||||
await saveNewsletterEmail({
|
||||
email: email.address,
|
||||
content: 'fake content 2',
|
||||
url: 'https://example.com/2',
|
||||
title: 'fake title',
|
||||
author: 'fake author',
|
||||
}, ctx)
|
||||
await saveNewsletterEmail(
|
||||
{
|
||||
email: email.address,
|
||||
content: `<html><body>fake content 2</body></html>`,
|
||||
url: 'https://example.com/2',
|
||||
title: 'fake title',
|
||||
author: 'fake author',
|
||||
},
|
||||
ctx
|
||||
)
|
||||
|
||||
setTimeout(async () => {
|
||||
const page = await getPageByParam({ userId: user.id })
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue