mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
5edead4446
Remove notification for university enrolment on affiliation add GitOrigin-RevId: 67df66ad6c6e9e16b6573fa15eb34293adaa0287
39 lines
1.3 KiB
CoffeeScript
39 lines
1.3 KiB
CoffeeScript
SandboxedModule = require('sandboxed-module')
|
|
assert = require('chai').assert
|
|
require('chai').should()
|
|
sinon = require('sinon')
|
|
modulePath = require('path').join __dirname, '../../../../app/js/Features/Notifications/NotificationsBuilder.js'
|
|
|
|
describe 'NotificationsBuilder', ->
|
|
user_id = "123nd3ijdks"
|
|
|
|
beforeEach ->
|
|
@handler =
|
|
createNotification: sinon.stub().callsArgWith(6)
|
|
|
|
@settings = apis: { v1: { url: 'v1.url', user: '', pass: '' } }
|
|
@body = {id: 1, name: 'stanford', enrolment_ad_html: 'v1 ad content'}
|
|
response = {statusCode: 200}
|
|
@request = sinon.stub().returns(@stubResponse).callsArgWith(1, null, response, @body)
|
|
@controller = SandboxedModule.require modulePath, requires:
|
|
"./NotificationsHandler":@handler
|
|
"settings-sharelatex":@settings
|
|
'request': @request
|
|
"logger-sharelatex":
|
|
log:->
|
|
err:->
|
|
|
|
it 'should call v1 and create affiliation notifications', (done)->
|
|
ip = '192.168.0.1'
|
|
@controller.ipMatcherAffiliation(user_id).create ip, (callback)=>
|
|
@request.calledOnce.should.equal true
|
|
expectedOpts =
|
|
university_name: @body.name
|
|
content: @body.enrolment_ad_html
|
|
@handler.createNotification.calledWith(
|
|
user_id,
|
|
"ip-matched-affiliation-#{@body.id}",
|
|
"notification_ip_matched_affiliation",
|
|
expectedOpts
|
|
).should.equal true
|
|
done()
|