mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Zotero Integration (#164)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { expect, vi } from 'vitest'
|
||||
import sinon from 'sinon'
|
||||
import LinkedFilesErrors from '../../../../app/src/Features/LinkedFiles/LinkedFilesErrors.mjs'
|
||||
const modulePath =
|
||||
'../../../../app/src/Features/LinkedFiles/LinkedFilesController.mjs'
|
||||
|
||||
@@ -224,6 +225,37 @@ describe('LinkedFilesController', function () {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('returns error 400 if user is not original importer', async function (ctx) {
|
||||
ctx.Agent.promises.refreshLinkedFile = sinon
|
||||
.stub()
|
||||
.rejects(
|
||||
new LinkedFilesErrors.NotOriginalImporterError(
|
||||
'Only the user who created the Zotero-linked file can refresh this file'
|
||||
)
|
||||
)
|
||||
|
||||
await new Promise(resolve => {
|
||||
ctx.next = sinon.stub().callsFake(() => resolve('unexpected error'))
|
||||
ctx.res = {
|
||||
status: sinon.stub().callsFake(code => {
|
||||
expect(code).to.equal(400)
|
||||
return ctx.res
|
||||
}),
|
||||
contentType: sinon.stub(),
|
||||
setHeader: sinon.stub(),
|
||||
send: sinon.stub(msg => {
|
||||
expect(msg).to.equal('You are not the user who originally imported this file')
|
||||
resolve()
|
||||
}),
|
||||
}
|
||||
|
||||
ctx.LinkedFilesController.refreshLinkedFile(ctx.req, ctx.res, ctx.next)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
expect(ctx.Agent.promises.refreshLinkedFile).to.not.have.been.called
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user