Fix some external requests not being mocked
This commit is contained in:
@ -384,7 +384,7 @@ const getJSONLdLinkMetadata = async (
|
||||
|
||||
return result
|
||||
} catch (error) {
|
||||
logger.warning(`Unable to get JSONLD link of the article`, error)
|
||||
logger.warning(`Unable to get JSONLD link of the article`, { error })
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,19 +11,23 @@ import { User } from '../../src/entity/user'
|
||||
describe('saveEmail', () => {
|
||||
const fakeContent = 'fake content'
|
||||
let user: User
|
||||
let scope: nock.Scope
|
||||
|
||||
before(async () => {
|
||||
// create test user
|
||||
user = await createTestUser('fakeUser')
|
||||
scope = nock('https://blog.omnivore.app')
|
||||
.get('/fake-url')
|
||||
.reply(200)
|
||||
.persist()
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await deleteTestUser(user.id)
|
||||
scope.persist(false)
|
||||
})
|
||||
|
||||
it('doesnt fail if saved twice', async () => {
|
||||
nock('https://blog.omnivore.app').get('/fake-url').reply(200)
|
||||
|
||||
const url = 'https://blog.omnivore.app/fake-url'
|
||||
const title = 'fake title'
|
||||
const author = 'fake author'
|
||||
|
||||
@ -90,6 +90,7 @@ describe('saveNewsletterEmail', () => {
|
||||
|
||||
it('adds a Newsletter label to that page', async () => {
|
||||
nock('https://blog.omnivore.app').get('/new-fake-url').reply(200)
|
||||
nock('https://blog.omnivore.app').head('/new-fake-url').reply(200)
|
||||
const url = 'https://blog.omnivore.app/new-fake-url'
|
||||
const newLabel = {
|
||||
name: 'Newsletter',
|
||||
|
||||
@ -22,9 +22,9 @@ const load = (path: string): string => {
|
||||
}
|
||||
|
||||
describe('parseMetadata', () => {
|
||||
it('gets author, title, image, description', async () => {
|
||||
it('gets author, title, image, description', () => {
|
||||
const html = load('./test/utils/data/substack-post.html')
|
||||
const metadata = await parsePageMetadata(html)
|
||||
const metadata = parsePageMetadata(html)
|
||||
expect(metadata?.author).to.deep.equal('Omnivore')
|
||||
expect(metadata?.title).to.deep.equal('Code Block Syntax Highlighting')
|
||||
expect(metadata?.previewImage).to.deep.equal(
|
||||
|
||||
Reference in New Issue
Block a user