mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-12 07:30:46 +02:00
2ad9f36706
GitOrigin-RevId: 6f413f4c5ef8d034b4e94afacdf2d7b43c3a8830
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
const SandboxedModule = require('sandboxed-module')
|
|
const sinon = require('sinon')
|
|
const { expect } = require('chai')
|
|
const modulePath = require('path').join(
|
|
__dirname,
|
|
'../../../../app/src/Features/Publishers/PublishersGetter.js'
|
|
)
|
|
|
|
describe('PublishersGetter', function () {
|
|
beforeEach(function () {
|
|
this.publisher = {
|
|
_id: 'mock-publsiher-id',
|
|
slug: 'ieee',
|
|
fetchV1Data: sinon.stub(),
|
|
}
|
|
|
|
this.UserMembershipsHandler = {
|
|
promises: {
|
|
getEntitiesByUser: sinon.stub().resolves([this.publisher]),
|
|
},
|
|
}
|
|
this.UserMembershipEntityConfigs = {
|
|
publisher: {
|
|
modelName: 'Publisher',
|
|
canCreate: true,
|
|
fields: {
|
|
primaryKey: 'slug',
|
|
},
|
|
},
|
|
}
|
|
|
|
this.PublishersGetter = SandboxedModule.require(modulePath, {
|
|
requires: {
|
|
'../User/UserGetter': this.UserGetter,
|
|
'../UserMembership/UserMembershipsHandler': this.UserMembershipsHandler,
|
|
'../UserMembership/UserMembershipEntityConfigs':
|
|
this.UserMembershipEntityConfigs,
|
|
},
|
|
})
|
|
|
|
this.userId = '12345abcde'
|
|
})
|
|
|
|
describe('getManagedPublishers', function () {
|
|
it('fetches v1 data before returning publisher list', async function () {
|
|
const publishers =
|
|
await this.PublishersGetter.promises.getManagedPublishers(this.userId)
|
|
expect(publishers.length).to.equal(1)
|
|
})
|
|
})
|
|
})
|