mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-17 21:05:04 -04:00
Merge pull request #20004 from overleaf/jel-plans-tests
[web] Add unit tests for new plans page GitOrigin-RevId: 8e5978d901d9faf123efbdd21ece65aad373cd94
This commit is contained in:
parent
8d63d56a6f
commit
2b463f3062
1 changed files with 51 additions and 4 deletions
|
@ -59,8 +59,6 @@ describe('SubscriptionController', function () {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
this.PlansLocator = { findLocalPlanInSettings: sinon.stub() }
|
|
||||||
|
|
||||||
this.LimitationsManager = {
|
this.LimitationsManager = {
|
||||||
hasPaidSubscription: sinon.stub(),
|
hasPaidSubscription: sinon.stub(),
|
||||||
userHasV1OrV2Subscription: sinon.stub(),
|
userHasV1OrV2Subscription: sinon.stub(),
|
||||||
|
@ -148,7 +146,6 @@ describe('SubscriptionController', function () {
|
||||||
'../Authentication/SessionManager': this.SessionManager,
|
'../Authentication/SessionManager': this.SessionManager,
|
||||||
'./SubscriptionHandler': this.SubscriptionHandler,
|
'./SubscriptionHandler': this.SubscriptionHandler,
|
||||||
'./SubscriptionHelper': this.SubscriptionHelper,
|
'./SubscriptionHelper': this.SubscriptionHelper,
|
||||||
'./PlansLocator': this.PlansLocator,
|
|
||||||
'./SubscriptionViewModelBuilder': this.SubscriptionViewModelBuilder,
|
'./SubscriptionViewModelBuilder': this.SubscriptionViewModelBuilder,
|
||||||
'./LimitationsManager': this.LimitationsManager,
|
'./LimitationsManager': this.LimitationsManager,
|
||||||
'../../infrastructure/GeoIpLookup': this.GeoIpLookup,
|
'../../infrastructure/GeoIpLookup': this.GeoIpLookup,
|
||||||
|
@ -176,6 +173,9 @@ describe('SubscriptionController', function () {
|
||||||
setUserPropertyForUser: sinon.stub(),
|
setUserPropertyForUser: sinon.stub(),
|
||||||
}),
|
}),
|
||||||
'../../infrastructure/Features': this.Features,
|
'../../infrastructure/Features': this.Features,
|
||||||
|
'../../util/currency': (this.currency = {
|
||||||
|
formatCurrencyLocalized: sinon.stub(),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -402,6 +402,30 @@ describe('SubscriptionController', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('localCcyAssignment', function () {
|
||||||
|
it('uses formatCurrencyLocalized when variant is enabled', function (done) {
|
||||||
|
this.SplitTestV2Hander.promises.getAssignment.resolves({
|
||||||
|
variant: 'enabled',
|
||||||
|
})
|
||||||
|
this.res.render = (page, opts) => {
|
||||||
|
expect(opts.formatCurrency).to.equal(
|
||||||
|
this.currency.formatCurrencyLocalized
|
||||||
|
)
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
this.SubscriptionController.plansPage(this.req, this.res)
|
||||||
|
})
|
||||||
|
it('uses formatCurrencyDefault when variant is default', function (done) {
|
||||||
|
this.res.render = (page, opts) => {
|
||||||
|
expect(opts.formatCurrency).to.equal(
|
||||||
|
this.SubscriptionHelper.formatCurrencyDefault
|
||||||
|
)
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
this.SubscriptionController.plansPage(this.req, this.res)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('plansPage light touch redesign', function () {
|
describe('plansPage light touch redesign', function () {
|
||||||
|
@ -619,6 +643,30 @@ describe('SubscriptionController', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('localCcyAssignment', function () {
|
||||||
|
it('uses formatCurrencyLocalized when variant is enabled', function (done) {
|
||||||
|
this.SplitTestV2Hander.promises.getAssignment.resolves({
|
||||||
|
variant: 'enabled',
|
||||||
|
})
|
||||||
|
this.res.render = (page, opts) => {
|
||||||
|
expect(opts.formatCurrency).to.equal(
|
||||||
|
this.currency.formatCurrencyLocalized
|
||||||
|
)
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
|
||||||
|
})
|
||||||
|
it('uses formatCurrencyDefault when variant is default', function (done) {
|
||||||
|
this.res.render = (page, opts) => {
|
||||||
|
expect(opts.formatCurrency).to.equal(
|
||||||
|
this.SubscriptionHelper.formatCurrencyDefault
|
||||||
|
)
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('interstitialPaymentPage', function () {
|
describe('interstitialPaymentPage', function () {
|
||||||
|
@ -641,7 +689,6 @@ describe('SubscriptionController', function () {
|
||||||
|
|
||||||
describe('with a user with subscription', function () {
|
describe('with a user with subscription', function () {
|
||||||
it('should redirect to the subscription dashboard', function (done) {
|
it('should redirect to the subscription dashboard', function (done) {
|
||||||
this.PlansLocator.findLocalPlanInSettings.returns({})
|
|
||||||
this.LimitationsManager.promises.userHasV1OrV2Subscription.resolves(
|
this.LimitationsManager.promises.userHasV1OrV2Subscription.resolves(
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue