mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-28 22:51:58 +00:00
Add a unit test for the analytics events sent from project-creation
This commit is contained in:
parent
d5109d22d2
commit
9dc8600588
1 changed files with 19 additions and 2 deletions
|
@ -52,7 +52,7 @@ describe 'ProjectCreationHandler', ->
|
|||
|
||||
@Settings = apis: { project_history: {} }
|
||||
|
||||
@AnalyticsManger = recordEvent: sinon.stub()
|
||||
@AnalyticsManager = recordEvent: sinon.stub()
|
||||
|
||||
@handler = SandboxedModule.require modulePath, requires:
|
||||
'../../models/User': User:@User
|
||||
|
@ -62,7 +62,7 @@ describe 'ProjectCreationHandler', ->
|
|||
'./ProjectEntityUpdateHandler':@ProjectEntityUpdateHandler
|
||||
"./ProjectDetailsHandler":@ProjectDetailsHandler
|
||||
"settings-sharelatex": @Settings
|
||||
"../Analytics/AnalyticsManager": @AnalyticsManger
|
||||
"../Analytics/AnalyticsManager": @AnalyticsManager
|
||||
'logger-sharelatex': {log:->}
|
||||
"metrics-sharelatex": {
|
||||
inc: ()->,
|
||||
|
@ -131,6 +131,23 @@ describe 'ProjectCreationHandler', ->
|
|||
expect(project.overleaf.history.display).to.equal true
|
||||
done()
|
||||
|
||||
it "should send a project-created event to analytics", (done) ->
|
||||
@handler.createBlankProject ownerId, projectName, (err, project) =>
|
||||
expect(@AnalyticsManager.recordEvent.callCount).to.equal 1
|
||||
expect(
|
||||
@AnalyticsManager.recordEvent.calledWith(ownerId, 'project-created')
|
||||
).to.equal true
|
||||
done()
|
||||
|
||||
it "should send a project-imported event when importing a project", (done) ->
|
||||
@handler.createBlankProject ownerId, projectName, 1234, (err, project) =>
|
||||
expect(@AnalyticsManager.recordEvent.callCount).to.equal 1
|
||||
expect(
|
||||
@AnalyticsManager.recordEvent.calledWith(ownerId, 'project-imported')
|
||||
).to.equal true
|
||||
done()
|
||||
|
||||
|
||||
describe "with an error", ->
|
||||
beforeEach ->
|
||||
@ProjectModel::save = sinon.stub().callsArgWith(0, new Error("something went wrong"))
|
||||
|
|
Loading…
Reference in a new issue