mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
mock webhook request
This commit is contained in:
parent
49de17bea5
commit
9981e506e4
1 changed files with 6 additions and 1 deletions
|
|
@ -5,10 +5,13 @@ import 'mocha'
|
|||
import { getRepository } from '../../src/entity/utils'
|
||||
import { Webhook } from '../../src/entity/webhook'
|
||||
import { expect } from 'chai'
|
||||
import nock from 'nock'
|
||||
|
||||
describe('Webhooks Router', () => {
|
||||
const username = 'fakeUser'
|
||||
const token = process.env.PUBSUB_VERIFICATION_TOKEN || ''
|
||||
const webhookBaseUrl = 'https://localhost:3000'
|
||||
const webhookPath = `/webhooks`
|
||||
|
||||
let user: User
|
||||
let webhook: Webhook
|
||||
|
|
@ -21,7 +24,7 @@ describe('Webhooks Router', () => {
|
|||
.send({ fakeEmail: user.email })
|
||||
|
||||
webhook = await getRepository(Webhook).save({
|
||||
url: 'https://example.com',
|
||||
url: webhookBaseUrl + webhookPath,
|
||||
user: { id: user.id },
|
||||
eventTypes: ['PAGE_CREATED'],
|
||||
})
|
||||
|
|
@ -43,6 +46,8 @@ describe('Webhooks Router', () => {
|
|||
},
|
||||
}
|
||||
|
||||
nock(webhookBaseUrl).post(webhookPath).reply(200)
|
||||
|
||||
const res = await request
|
||||
.post('/svc/pubsub/webhooks/trigger/created?token=' + token)
|
||||
.send(data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue