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
87b4ec503e
commit
016775aadb
3 changed files with 32 additions and 35 deletions
|
|
@ -646,8 +646,8 @@ describe('Article API', () => {
|
|||
|
||||
context('when the source is rss-feeder and url is from youtube.com', () => {
|
||||
const source = 'rss-feeder'
|
||||
const stub = sinon.stub(createTask, 'enqueueParseRequest')
|
||||
const stub2 = sinon.stub(createTask, 'enqueueProcessYouTubeVideo')
|
||||
const stub = sinon.stub(createTask, 'enqueueFetchContentJob')
|
||||
sinon.stub(createTask, 'enqueueProcessYouTubeVideo')
|
||||
|
||||
before(() => {
|
||||
url = 'https://www.youtube.com/watch?v=123'
|
||||
|
|
@ -678,7 +678,11 @@ describe('Article API', () => {
|
|||
const url = 'https://blog.omnivore.app/new-url-1'
|
||||
|
||||
before(() => {
|
||||
sinon.replace(createTask, 'enqueueParseRequest', sinon.fake.resolves(''))
|
||||
sinon.replace(
|
||||
createTask,
|
||||
'enqueueFetchContentJob',
|
||||
sinon.fake.resolves('')
|
||||
)
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
|||
|
|
@ -13,17 +13,9 @@ import * as createTask from '../../src/utils/createTask'
|
|||
import { createTestUser } from '../db'
|
||||
import { graphqlRequest, request } from '../util'
|
||||
|
||||
const articleSavingRequestQuery = ({
|
||||
id,
|
||||
url,
|
||||
}: {
|
||||
id?: string
|
||||
url?: string
|
||||
}) => `
|
||||
query {
|
||||
articleSavingRequest(id: ${id ? `"${id}"` : null}, url: ${
|
||||
url ? `"${url}"` : null
|
||||
}) {
|
||||
const articleSavingRequestQuery = `
|
||||
query ArticleSavingRequest($id: ID, $url: String) {
|
||||
articleSavingRequest(id: $id, url: $url) {
|
||||
... on ArticleSavingRequestSuccess {
|
||||
articleSavingRequest {
|
||||
id
|
||||
|
|
@ -74,9 +66,9 @@ describe('ArticleSavingRequest API', () => {
|
|||
.post('/local/debug/fake-user-login')
|
||||
.send({ fakeEmail: user.email })
|
||||
|
||||
authToken = res.body.authToken
|
||||
authToken = res.body.authToken as string
|
||||
|
||||
sinon.replace(createTask, 'enqueueParseRequest', sinon.fake.resolves(''))
|
||||
sinon.replace(createTask, 'enqueueFetchContentJob', sinon.fake.resolves(''))
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
|
|
@ -131,14 +123,14 @@ describe('ArticleSavingRequest API', () => {
|
|||
createArticleSavingRequestMutation(url),
|
||||
authToken
|
||||
).expect(200)
|
||||
id = res.body.data.createArticleSavingRequest.articleSavingRequest.id
|
||||
id = res.body.data.createArticleSavingRequest.articleSavingRequest
|
||||
.id as string
|
||||
})
|
||||
|
||||
it('returns the article saving request if exists', async () => {
|
||||
const res = await graphqlRequest(
|
||||
articleSavingRequestQuery({ url }),
|
||||
authToken
|
||||
).expect(200)
|
||||
const res = await graphqlRequest(articleSavingRequestQuery, authToken, {
|
||||
id,
|
||||
}).expect(200)
|
||||
|
||||
expect(
|
||||
res.body.data.articleSavingRequest.articleSavingRequest.status
|
||||
|
|
@ -146,10 +138,9 @@ describe('ArticleSavingRequest API', () => {
|
|||
})
|
||||
|
||||
it('returns the user profile info', async () => {
|
||||
const res = await graphqlRequest(
|
||||
articleSavingRequestQuery({ url }),
|
||||
authToken
|
||||
).expect(200)
|
||||
const res = await graphqlRequest(articleSavingRequestQuery, authToken, {
|
||||
url,
|
||||
}).expect(200)
|
||||
|
||||
expect(
|
||||
res.body.data.articleSavingRequest.articleSavingRequest.user.profile
|
||||
|
|
@ -158,10 +149,9 @@ describe('ArticleSavingRequest API', () => {
|
|||
})
|
||||
|
||||
it('returns the article saving request by id', async () => {
|
||||
const res = await graphqlRequest(
|
||||
articleSavingRequestQuery({ id }),
|
||||
authToken
|
||||
).expect(200)
|
||||
const res = await graphqlRequest(articleSavingRequestQuery, authToken, {
|
||||
id,
|
||||
}).expect(200)
|
||||
|
||||
expect(
|
||||
res.body.data.articleSavingRequest.articleSavingRequest.status
|
||||
|
|
@ -169,10 +159,9 @@ describe('ArticleSavingRequest API', () => {
|
|||
})
|
||||
|
||||
it('returns not_found if not exists', async () => {
|
||||
const res = await graphqlRequest(
|
||||
articleSavingRequestQuery({ id: 'invalid-id' }),
|
||||
authToken
|
||||
).expect(200)
|
||||
const res = await graphqlRequest(articleSavingRequestQuery, authToken, {
|
||||
id: 'invalid-id',
|
||||
}).expect(200)
|
||||
|
||||
expect(res.body.data.articleSavingRequest.errorCodes).to.eql([
|
||||
ArticleSavingRequestErrorCode.NotFound,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ describe('/article/save API', () => {
|
|||
.post('/local/debug/fake-user-login')
|
||||
.send({ fakeEmail: user.email })
|
||||
|
||||
authToken = res.body.authToken
|
||||
authToken = res.body.authToken as string
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
|
|
@ -39,7 +39,11 @@ describe('/article/save API', () => {
|
|||
const url = 'https://blog.omnivore.app'
|
||||
|
||||
before(() => {
|
||||
sinon.replace(createTask, 'enqueueParseRequest', sinon.fake.resolves(''))
|
||||
sinon.replace(
|
||||
createTask,
|
||||
'enqueueFetchContentJob',
|
||||
sinon.fake.resolves('')
|
||||
)
|
||||
})
|
||||
|
||||
after(() => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue