mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-23 13:31:21 +00:00
add csv export unit tests
This commit is contained in:
parent
f50eb0398f
commit
f709ddf3eb
1 changed files with 31 additions and 3 deletions
|
@ -3,16 +3,17 @@ should = require('chai').should()
|
|||
sinon = require 'sinon'
|
||||
assert = require("chai").assert
|
||||
modulePath = "../../../../app/js/Features/Subscription/SubscriptionGroupController"
|
||||
|
||||
MockResponse = require "../helpers/MockResponse"
|
||||
|
||||
describe "Subscription Group Controller", ->
|
||||
|
||||
beforeEach ->
|
||||
@user = {_id:"!@312431"}
|
||||
@user = {_id:"!@312431",email:"user@email.com"}
|
||||
@subscription = {}
|
||||
@GroupHandler =
|
||||
addUserToGroup: sinon.stub().callsArgWith(2, null, @user)
|
||||
removeUserFromGroup: sinon.stub().callsArgWith(2)
|
||||
getPopulatedListOfMembers: sinon.stub().callsArgWith(1, null, [@user])
|
||||
@SubscriptionLocator = getUsersSubscription: sinon.stub().callsArgWith(1, null, @subscription)
|
||||
|
||||
@Controller = SandboxedModule.require modulePath, requires:
|
||||
|
@ -52,10 +53,37 @@ describe "Subscription Group Controller", ->
|
|||
|
||||
describe "renderSubscriptionGroupAdminPage", ->
|
||||
it "should redirect you if you don't have a group account", (done)->
|
||||
@subscription.group = false
|
||||
@subscription.groupPlan = false
|
||||
|
||||
res =
|
||||
redirect : (path)=>
|
||||
path.should.equal("/")
|
||||
done()
|
||||
@Controller.renderSubscriptionGroupAdminPage @req, res
|
||||
|
||||
describe "exportGroupCsv", ->
|
||||
|
||||
beforeEach ->
|
||||
@subscription.groupPlan = true
|
||||
@res = new MockResponse()
|
||||
@res.contentType = sinon.stub()
|
||||
@res.header = sinon.stub()
|
||||
@res.send = sinon.stub()
|
||||
@Controller.exportGroupCsv @req, @res
|
||||
|
||||
it "should set the correct content type on the request", ->
|
||||
@res.contentType
|
||||
.calledWith("text/csv")
|
||||
.should.equal true
|
||||
|
||||
it "should name the exported csv file", ->
|
||||
@res.header
|
||||
.calledWith(
|
||||
"Content-Disposition",
|
||||
"attachment; filename=Group.csv")
|
||||
.should.equal true
|
||||
|
||||
it "should export the correct csv", ->
|
||||
@res.send
|
||||
.calledWith("user@email.com\n")
|
||||
.should.equal true
|
||||
|
|
Loading…
Reference in a new issue