Files
overleaf-cep/services/web/test/unit/src/Publishers/PublishersGetterTests.js
T
Andrew Rumble 2ad9f36706 Promisify tests
GitOrigin-RevId: 6f413f4c5ef8d034b4e94afacdf2d7b43c3a8830
2025-04-29 08:05:18 +00:00

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)
})
})
})