mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-11 15:10:48 +02:00
Merge pull request #1717 from overleaf/as-decaffeinate-backend
Decaffeinate backend GitOrigin-RevId: 4ca9f94fc809cab6f47cec8254cacaf1bb3806fa
This commit is contained in:
committed by
sharelatex
parent
d4eb71b525
commit
0ca81de78c
@@ -0,0 +1,90 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const assert = require('assert')
|
||||
require('chai').should()
|
||||
const sinon = require('sinon')
|
||||
const modulePath = require('path').join(
|
||||
__dirname,
|
||||
'../../../../app/src/Features/Notifications/NotificationsController.js'
|
||||
)
|
||||
|
||||
describe('NotificationsController', function() {
|
||||
const user_id = '123nd3ijdks'
|
||||
const notification_id = '123njdskj9jlk'
|
||||
|
||||
beforeEach(function() {
|
||||
this.handler = {
|
||||
getUserNotifications: sinon.stub().callsArgWith(1),
|
||||
markAsRead: sinon.stub().callsArgWith(2)
|
||||
}
|
||||
this.req = {
|
||||
params: {
|
||||
notification_id
|
||||
},
|
||||
session: {
|
||||
user: {
|
||||
_id: user_id
|
||||
}
|
||||
},
|
||||
i18n: {
|
||||
translate() {}
|
||||
}
|
||||
}
|
||||
this.AuthenticationController = {
|
||||
getLoggedInUserId: sinon.stub().returns(this.req.session.user._id)
|
||||
}
|
||||
return (this.controller = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'./NotificationsHandler': this.handler,
|
||||
underscore: (this.underscore = {
|
||||
map(arr) {
|
||||
return arr
|
||||
}
|
||||
}),
|
||||
'logger-sharelatex': {
|
||||
log() {},
|
||||
err() {}
|
||||
},
|
||||
'../Authentication/AuthenticationController': this
|
||||
.AuthenticationController
|
||||
}
|
||||
}))
|
||||
})
|
||||
|
||||
it('should ask the handler for all unread notifications', function(done) {
|
||||
const allNotifications = [{ _id: notification_id, user_id }]
|
||||
this.handler.getUserNotifications = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null, allNotifications)
|
||||
return this.controller.getAllUnreadNotifications(this.req, {
|
||||
send: body => {
|
||||
body.should.equal(allNotifications)
|
||||
this.handler.getUserNotifications.calledWith(user_id).should.equal(true)
|
||||
return done()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return it('should send a delete request when a delete has been received to mark a notification', function(done) {
|
||||
return this.controller.markNotificationAsRead(this.req, {
|
||||
send: () => {
|
||||
this.handler.markAsRead
|
||||
.calledWith(user_id, notification_id)
|
||||
.should.equal(true)
|
||||
return done()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user