Unit test tracking code.

This commit is contained in:
Paulo Reis
2016-08-11 14:09:57 +01:00
parent 9bf9df9a4a
commit 228de5332e
2 changed files with 14 additions and 0 deletions
@@ -19,6 +19,7 @@ describe "AuthenticationController", ->
"../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() }
"../Security/LoginRateLimiter": @LoginRateLimiter = { processLoginRequest:sinon.stub(), recordSuccessfulLogin:sinon.stub() }
"../User/UserHandler": @UserHandler = {setupLoginData:sinon.stub()}
"../Analytics/AnalyticsManager": @AnalyticsManager = { recordEvent: sinon.stub() }
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
"settings-sharelatex": {}
"../User/UserSessionsManager": @UserSessionsManager =
@@ -100,6 +101,11 @@ describe "AuthenticationController", ->
.calledWith(email: @email.toLowerCase(), user_id: @user._id.toString(), "successful log in")
.should.equal true
it "should track the login event", ->
@AnalyticsManager.recordEvent
.calledWith(@user._id, "user-logged-in")
.should.equal true
describe 'when the user is not authenticated', ->
beforeEach ->
@@ -33,6 +33,7 @@ describe "UserRegistrationHandler", ->
"crypto": @crypto = {}
"../Email/EmailHandler": @EmailHandler
"../Security/OneTimeTokenHandler": @OneTimeTokenHandler
"../Analytics/AnalyticsManager": @AnalyticsManager = { recordEvent: sinon.stub() }
"settings-sharelatex": @settings = {siteUrl: "http://sl.example.com"}
@passingRequest = {email:"something@email.com", password:"123"}
@@ -132,6 +133,13 @@ describe "UserRegistrationHandler", ->
@NewsLetterManager.subscribe.calledWith(@user).should.equal true
done()
it "should track the registration event", (done)->
@handler.registerNewUser @passingRequest, (err)=>
@AnalyticsManager.recordEvent
.calledWith(@user._id, "user-registered")
.should.equal true
done()
it "should call the ReferalAllocator", (done)->
done()