mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-12 11:04:48 +00:00
Add test for the updateEditingSession endpoint
This commit is contained in:
parent
0bef5531bb
commit
8dbb89c09e
1 changed files with 23 additions and 8 deletions
|
@ -14,23 +14,38 @@ describe 'AnalyticsController', ->
|
|||
getLoggedInUserId: sinon.stub()
|
||||
|
||||
@AnalyticsManager =
|
||||
updateEditingSession: sinon.stub().callsArgWith(3)
|
||||
recordEvent: sinon.stub().callsArgWith(3)
|
||||
|
||||
@req =
|
||||
params:
|
||||
event:"i_did_something"
|
||||
body:"stuff"
|
||||
sessionID: "sessionIDHere"
|
||||
|
||||
@res =
|
||||
send:->
|
||||
@controller = SandboxedModule.require modulePath, requires:
|
||||
"./AnalyticsManager":@AnalyticsManager
|
||||
"../Authentication/AuthenticationController":@AuthenticationController
|
||||
"logger-sharelatex":
|
||||
log:->
|
||||
|
||||
@res =
|
||||
send:->
|
||||
|
||||
describe "updateEditingSession", ->
|
||||
beforeEach ->
|
||||
@req =
|
||||
params:
|
||||
projectId: "a project id"
|
||||
|
||||
it "delegates to the AnalyticsManager", (done) ->
|
||||
@AuthenticationController.getLoggedInUserId.returns("1234")
|
||||
@controller.updateEditingSession @req, @res
|
||||
|
||||
@AnalyticsManager.updateEditingSession.calledWith("1234", "a project id", {}).should.equal true
|
||||
done()
|
||||
|
||||
describe "recordEvent", ->
|
||||
beforeEach ->
|
||||
@req =
|
||||
params:
|
||||
event:"i_did_something"
|
||||
body:"stuff"
|
||||
sessionID: "sessionIDHere"
|
||||
|
||||
it "should use the user_id", (done)->
|
||||
@AuthenticationController.getLoggedInUserId.returns("1234")
|
||||
|
|
Loading…
Add table
Reference in a new issue