mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 03:43:41 +00:00
Add tests for getting V1 projects
This commit is contained in:
parent
9bf74f29bd
commit
fff6873e10
1 changed files with 35 additions and 1 deletions
|
@ -54,6 +54,8 @@ describe "ProjectController", ->
|
|||
@ProjectGetter =
|
||||
findAllUsersProjects: sinon.stub()
|
||||
getProject: sinon.stub()
|
||||
@V1ProjectGetter =
|
||||
findAllUsersProjects: sinon.stub()
|
||||
@AuthenticationController =
|
||||
getLoggedInUser: sinon.stub().callsArgWith(1, null, @user)
|
||||
getLoggedInUserId: sinon.stub().returns(@user._id)
|
||||
|
@ -89,6 +91,7 @@ describe "ProjectController", ->
|
|||
"./ProjectUpdateHandler":@ProjectUpdateHandler
|
||||
"../ReferencesSearch/ReferencesSearchHandler": @ReferencesSearchHandler
|
||||
"./ProjectGetter": @ProjectGetter
|
||||
'./V1ProjectGetter': @V1ProjectGetter
|
||||
'../Authentication/AuthenticationController': @AuthenticationController
|
||||
"../Analytics/AnalyticsManager": @AnalyticsManager
|
||||
"../TokenAccess/TokenAccessHandler": @TokenAccessHandler
|
||||
|
@ -263,6 +266,7 @@ describe "ProjectController", ->
|
|||
@TagsHandler.getAllTags.callsArgWith(1, null, @tags, {})
|
||||
@NotificationsHandler.getUserNotifications = sinon.stub().callsArgWith(1, null, @notifications, {})
|
||||
@ProjectGetter.findAllUsersProjects.callsArgWith(2, null, @allProjects)
|
||||
@V1ProjectGetter.findAllUsersProjects.callsArg(1) # Without integration module cb returns without args
|
||||
|
||||
it "should render the project/list page", (done)->
|
||||
@res.render = (pageName, opts)=>
|
||||
|
@ -278,7 +282,7 @@ describe "ProjectController", ->
|
|||
|
||||
it "should send the projects", (done)->
|
||||
@res.render = (pageName, opts)=>
|
||||
opts.projects.length.should.equal (@projects.length + @collabertions.length + @readOnly.length + @tokenReadAndWrite.length + @tokenReadOnly.length)
|
||||
opts.projects.length.should.equal (@projects.length + @collabertions.length + @readOnly.length)
|
||||
done()
|
||||
@ProjectController.projectListPage @req, @res
|
||||
|
||||
|
@ -295,6 +299,36 @@ describe "ProjectController", ->
|
|||
done()
|
||||
@ProjectController.projectListPage @req, @res
|
||||
|
||||
describe 'with overleaf-integration-web-module', ->
|
||||
beforeEach ->
|
||||
@V1Response =
|
||||
projects: [
|
||||
{ id: '123mockV1Id', title: 'mock title', updated_at: 1509616411, removed: false, archived: false }
|
||||
{ id: '456mockV1Id', title: 'mock title 2', updated_at: 1509616411, removed: true, archived: false }
|
||||
],
|
||||
tags: [
|
||||
{ name: 'mock tag', project_ids: ['123mockV1Id'] }
|
||||
]
|
||||
@V1ProjectGetter.findAllUsersProjects.callsArgWith(1, null, @V1Response)
|
||||
|
||||
it 'should include V1 projects', (done) ->
|
||||
@res.render = (pageName, opts) =>
|
||||
opts.projects.length.should.equal (@projects.length + @collabertions.length + @readOnly.length + @V1Response.projects.length)
|
||||
done()
|
||||
@ProjectController.projectListPage @req, @res
|
||||
|
||||
it 'should include V1 tags', (done) ->
|
||||
@res.render = (pageName, opts) =>
|
||||
opts.tags.length.should.equal (@tags.length + @V1Response.tags.length)
|
||||
done()
|
||||
@ProjectController.projectListPage @req, @res
|
||||
|
||||
it 'should have isShowingV1Projects flag', (done) ->
|
||||
@res.render = (pageName, opts) =>
|
||||
opts.isShowingV1Projects.should.equal true
|
||||
done()
|
||||
@ProjectController.projectListPage @req, @res
|
||||
|
||||
describe "projectListPage with duplicate projects", ->
|
||||
|
||||
beforeEach ->
|
||||
|
|
Loading…
Reference in a new issue