Merge pull request #2182 from overleaf/ta-remove-user-stubs
Remove Usages of UserStub GitOrigin-RevId: 6896d0d3594d12ffa06211838ae2274661c77f4f
This commit is contained in:
committed by
sharelatex
parent
962c5cc273
commit
2eb1f510c1
@@ -24,7 +24,7 @@ const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
describe('UserMembershipViewModel', function() {
|
||||
beforeEach(function() {
|
||||
this.UserGetter = { getUserOrUserStubById: sinon.stub() }
|
||||
this.UserGetter = { getUser: sinon.stub() }
|
||||
this.UserMembershipViewModel = SandboxedModule.require(modulePath, {
|
||||
globals: {
|
||||
console: console
|
||||
@@ -40,10 +40,6 @@ describe('UserMembershipViewModel', function() {
|
||||
email: 'mock-email@baz.com',
|
||||
first_name: 'Name'
|
||||
}
|
||||
return (this.userStub = {
|
||||
_id: 'mock-user-stub-id',
|
||||
email: 'mock-stub-email@baz.com'
|
||||
})
|
||||
})
|
||||
|
||||
describe('build', function() {
|
||||
@@ -92,7 +88,7 @@ describe('UserMembershipViewModel', function() {
|
||||
})
|
||||
|
||||
it('build user id', function(done) {
|
||||
this.UserGetter.getUserOrUserStubById.yields(null, this.user, false)
|
||||
this.UserGetter.getUser.yields(null, this.user)
|
||||
return this.UserMembershipViewModel.buildAsync(
|
||||
ObjectId(),
|
||||
(error, viewModel) => {
|
||||
@@ -108,23 +104,8 @@ describe('UserMembershipViewModel', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('build user stub id', function(done) {
|
||||
this.UserGetter.getUserOrUserStubById.yields(null, this.userStub, true)
|
||||
return this.UserMembershipViewModel.buildAsync(
|
||||
ObjectId(),
|
||||
(error, viewModel) => {
|
||||
should.not.exist(error)
|
||||
assertNotCalled(this.UserMembershipViewModel.build)
|
||||
expect(viewModel._id).to.equal(this.userStub._id)
|
||||
expect(viewModel.email).to.equal(this.userStub.email)
|
||||
expect(viewModel.invite).to.equal(true)
|
||||
return done()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('build user id with error', function(done) {
|
||||
this.UserGetter.getUserOrUserStubById.yields(new Error('nope'))
|
||||
this.UserGetter.getUser.yields(new Error('nope'))
|
||||
const userId = ObjectId()
|
||||
return this.UserMembershipViewModel.buildAsync(
|
||||
userId,
|
||||
|
||||
Reference in New Issue
Block a user