|
@@ -17,9 +17,13 @@ describe 'AnalyticsController', ->
|
|
|
updateEditingSession: sinon.stub().callsArgWith(3)
|
|
updateEditingSession: sinon.stub().callsArgWith(3)
|
|
|
recordEvent: sinon.stub().callsArgWith(3)
|
|
recordEvent: sinon.stub().callsArgWith(3)
|
|
|
|
|
|
|
|
|
|
+ @InstitutionsAPI =
|
|
|
|
|
+ getInstitutionLicences: sinon.stub().callsArgWith(4)
|
|
|
|
|
+
|
|
|
@controller = SandboxedModule.require modulePath, requires:
|
|
@controller = SandboxedModule.require modulePath, requires:
|
|
|
"./AnalyticsManager":@AnalyticsManager
|
|
"./AnalyticsManager":@AnalyticsManager
|
|
|
"../Authentication/AuthenticationController":@AuthenticationController
|
|
"../Authentication/AuthenticationController":@AuthenticationController
|
|
|
|
|
+ "../Institutions/InstitutionsAPI":@InstitutionsAPI
|
|
|
"logger-sharelatex":
|
|
"logger-sharelatex":
|
|
|
log:->
|
|
log:->
|
|
|
'../../infrastructure/GeoIpLookup': @GeoIpLookup =
|
|
'../../infrastructure/GeoIpLookup': @GeoIpLookup =
|
|
@@ -66,3 +70,19 @@ describe 'AnalyticsController', ->
|
|
|
@controller.recordEvent @req, @res
|
|
@controller.recordEvent @req, @res
|
|
|
@AnalyticsManager.recordEvent.calledWith(@req.sessionID, @req.params["event"], @req.body).should.equal true
|
|
@AnalyticsManager.recordEvent.calledWith(@req.sessionID, @req.params["event"], @req.body).should.equal true
|
|
|
done()
|
|
done()
|
|
|
|
|
+
|
|
|
|
|
+ describe "licences", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @req =
|
|
|
|
|
+ query:
|
|
|
|
|
+ resource_id:1
|
|
|
|
|
+ start_date:'1514764800'
|
|
|
|
|
+ end_date:'1530662400'
|
|
|
|
|
+ resource_type:'institution'
|
|
|
|
|
+ sessionID: "sessionIDHere"
|
|
|
|
|
+ session: {}
|
|
|
|
|
+
|
|
|
|
|
+ it "should trigger institutions api to fetch licences graph data", (done)->
|
|
|
|
|
+ @controller.licences @req, @res
|
|
|
|
|
+ @InstitutionsAPI.getInstitutionLicences.calledWith(@req.query["resource_id"], @req.query["start_date"], @req.query["end_date"], @req.query["lag"]).should.equal true
|
|
|
|
|
+ done()
|