mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
very start of chat controllers done
This commit is contained in:
parent
77246b2a07
commit
9c35cfd693
2 changed files with 55 additions and 0 deletions
12
services/web/app/coffee/Features/Chat/ChatController.coffee
Normal file
12
services/web/app/coffee/Features/Chat/ChatController.coffee
Normal file
|
@ -0,0 +1,12 @@
|
|||
ChatHandler = require("./ChatHandler")
|
||||
|
||||
module.exports =
|
||||
|
||||
|
||||
sendMessage: (project_id, user_id, messageContent, callback)->
|
||||
ChatHandler.sendMessage project_id, user_id, messageContent, (err)->
|
||||
callback()
|
||||
|
||||
getMessages: (project_id, query, callback)->
|
||||
ChatHandler.getMessages project_id, query, (err)->
|
||||
callback()
|
|
@ -0,0 +1,43 @@
|
|||
should = require('chai').should()
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
assert = require('assert')
|
||||
path = require('path')
|
||||
sinon = require('sinon')
|
||||
modulePath = path.join __dirname, "../../../../app/js/Features/Chat/ChatController"
|
||||
expect = require("chai").expect
|
||||
|
||||
describe "ChatController", ->
|
||||
|
||||
beforeEach ->
|
||||
|
||||
@settings = {}
|
||||
@ChatHandler =
|
||||
sendMessage:sinon.stub()
|
||||
getMessages:sinon.stub()
|
||||
|
||||
@ChatController = SandboxedModule.require modulePath, requires:
|
||||
"settings-sharelatex":@settings
|
||||
"logger-sharelatex": log:->
|
||||
"./ChatHandler":@ChatHandler
|
||||
@query =
|
||||
before:"some time"
|
||||
|
||||
|
||||
|
||||
describe "sendMessage", ->
|
||||
|
||||
it "should tell the chat handler about the message", (done)->
|
||||
@ChatHandler.sendMessage.callsArgWith(3)
|
||||
@ChatController.sendMessage @project_id, @user_id, @messageContent, (err)=>
|
||||
@ChatHandler.sendMessage.calledWith(@project_id, @user_id, @messageContent).should.equal true
|
||||
done()
|
||||
|
||||
describe "getMessages", ->
|
||||
|
||||
it "should tell the chat handler about the request", (done)->
|
||||
|
||||
@ChatHandler.getMessages.callsArgWith(2)
|
||||
@ChatController.getMessages @project_id, @query, (err)=>
|
||||
@ChatHandler.getMessages.calledWith(@project_id, @query).should.equal true
|
||||
done()
|
||||
|
Loading…
Reference in a new issue