Files
omnivore/packages/api/test/routers/article_router.test.ts
Hongbo Wu a04e91472d fix a bug of using article as table name in the reminders query (#34)
* fix a bug of using article as table name in the reminders query

* fix test

* increase timeout value

* increase timeout value to 50000

* add import mocha

* add import mocha for label test

* add import mocha for every test

* fix test in deleting labels

* add timeout for each label test

* one more test

* fix reminders router by allowing sendrid template id to be null

* do not retry if reminders not found
2022-02-14 13:59:04 +08:00

51 lines
1.3 KiB
TypeScript

import { createTestUser, deleteTestUser } from '../db'
import { request } from '../util'
import { expect } from 'chai'
import nock from 'nock'
import 'mocha'
describe('/article/save API', () => {
const username = 'fakeUser'
let authToken: string
// We need to mock the pupeeteer-parse
// service here because in dev mode the task gets
// called immediately.
nock('http://localhost:8080/').post('/').reply(200)
before(async () => {
// create test user and login
const user = await createTestUser(username)
const res = await request
.post('/local/debug/fake-user-login')
.send({ fakeEmail: user.email })
authToken = res.body.authToken
})
after(async () => {
// clean up
await deleteTestUser(username)
})
describe('POST /article/save', () => {
const url = 'https://www.example.com'
context('when token and url are valid', () => {
it('should create an article saving request', async () => {
const response = await request
.post('/api/article/save')
.send({
url,
v: '0.2.18',
})
.set('Accept', 'application/x-www-form-urlencoded')
.set('Cookie', `auth=${authToken}`)
expect(response.body.articleSavingRequestId).to.be.a('string')
})
})
})
})