mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fix some external requests not being mocked
This commit is contained in:
parent
42dc3f7330
commit
ef800ded81
4 changed files with 26 additions and 1 deletions
|
|
@ -15,6 +15,8 @@ import {
|
|||
import * as createTask from '../../src/utils/createTask'
|
||||
import { createTestUser, deleteTestUser } from '../db'
|
||||
import { graphqlRequest, request } from '../util'
|
||||
import sinon from 'sinon'
|
||||
import * as createTask from '../../src/utils/createTask'
|
||||
|
||||
const articleSavingRequestQuery = ({
|
||||
id,
|
||||
|
|
@ -89,6 +91,14 @@ describe('ArticleSavingRequest API', () => {
|
|||
})
|
||||
|
||||
describe('createArticleSavingRequest', () => {
|
||||
before(() => {
|
||||
sinon.replace(createTask, 'enqueueParseRequest', sinon.fake.resolves(''))
|
||||
})
|
||||
|
||||
after(() => {
|
||||
sinon.restore()
|
||||
})
|
||||
|
||||
it('returns the article saving request', async () => {
|
||||
const res = await graphqlRequest(
|
||||
createArticleSavingRequestMutation('https://blog.omnivore.app'),
|
||||
|
|
|
|||
|
|
@ -86,6 +86,11 @@ describe('Integrations resolvers', () => {
|
|||
context('when token is invalid', () => {
|
||||
before(() => {
|
||||
token = 'invalid token'
|
||||
nock(READWISE_API_URL, {
|
||||
reqheaders: { Authorization: `Token ${token}` },
|
||||
})
|
||||
.get('/auth')
|
||||
.reply(401)
|
||||
})
|
||||
|
||||
it('returns InvalidToken error code', async () => {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import nock from 'nock'
|
|||
import 'mocha'
|
||||
import { env } from '../../src/env'
|
||||
import { User } from '../../src/entity/user'
|
||||
import sinon from 'sinon'
|
||||
import * as createTask from '../../src/utils/createTask'
|
||||
|
||||
describe('/article/save API', () => {
|
||||
let user: User
|
||||
|
|
@ -33,6 +35,14 @@ describe('/article/save API', () => {
|
|||
describe('POST /article/save', () => {
|
||||
const url = 'https://blog.omnivore.app'
|
||||
|
||||
before(() => {
|
||||
sinon.replace(createTask, 'enqueueParseRequest', sinon.fake.resolves(''))
|
||||
})
|
||||
|
||||
after(() => {
|
||||
sinon.restore()
|
||||
})
|
||||
|
||||
context('when token and url are valid', () => {
|
||||
it('should create an article saving request', async () => {
|
||||
const response = await request
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ describe('Integrations routers', () => {
|
|||
|
||||
context('when token is valid', () => {
|
||||
before(() => {
|
||||
token = process.env.PUBSUB_VERIFICATION_TOKEN!
|
||||
token = process.env.PUBSUB_VERIFICATION_TOKEN as string
|
||||
})
|
||||
|
||||
context('when data is expired', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue