Merge pull request #22539 from overleaf/mf-move-plansbanners-helper-to-module

[web] Move "plansBanners" function (along with its tests) to subscription module

GitOrigin-RevId: a231ecd862e7f052ca2597eb07d6612b23f2c7d3
This commit is contained in:
M Fahru
2025-01-14 08:43:47 -07:00
committed by Copybot
parent ef5a52b29d
commit 4150baefcb

View File

@@ -272,114 +272,6 @@ describe('SubscriptionController', function () {
})
})
describe('showInrGeoBanner data', function () {
it('should return true for Indian Users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans')
opts.showInrGeoBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'IN',
})
this.SubscriptionController.plansPage(this.req, this.res)
})
it('should return false for US Users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans')
opts.showInrGeoBanner.should.equal(false)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'US',
})
this.SubscriptionController.plansPage(this.req, this.res)
})
})
describe('showBrlGeoBanner data', function () {
it('should return true for Brazilian users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans')
opts.showBrlGeoBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'BR',
})
this.SubscriptionController.plansPage(this.req, this.res)
})
it('should return false for US users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans')
opts.showBrlGeoBanner.should.equal(false)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'US',
})
this.SubscriptionController.plansPage(this.req, this.res)
})
})
describe('showLATAMBanner', function () {
it('should return true for Mexican users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'MX',
})
this.SubscriptionController.plansPage(this.req, this.res)
})
it('should return true for Colombian users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'CO',
})
this.SubscriptionController.plansPage(this.req, this.res)
})
it('should return true for Chilean users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'CL',
})
this.SubscriptionController.plansPage(this.req, this.res)
})
it('should return true for Peruvian users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'PE',
})
this.SubscriptionController.plansPage(this.req, this.res)
})
it('should return true for US users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans')
opts.showLATAMBanner.should.equal(false)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'US',
})
this.SubscriptionController.plansPage(this.req, this.res)
})
})
describe('formatCurrency data', function () {
it('return correct formatCurrency function', function (done) {
this.res.render = (page, opts) => {
@@ -485,114 +377,6 @@ describe('SubscriptionController', function () {
})
})
describe('showInrGeoBanner data', function () {
it('should return true for Indian Users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans-light-design')
opts.showInrGeoBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'IN',
})
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
})
it('should return false for US Users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans-light-design')
opts.showInrGeoBanner.should.equal(false)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'US',
})
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
})
})
describe('showBrlGeoBanner data', function () {
it('should return true for Brazilian users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans-light-design')
opts.showBrlGeoBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'BR',
})
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
})
it('should return false for US users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans-light-design')
opts.showBrlGeoBanner.should.equal(false)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'US',
})
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
})
})
describe('showLATAMBanner', function () {
it('should return true for Mexican users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans-light-design')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'MX',
})
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
})
it('should return true for Colombian users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans-light-design')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'CO',
})
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
})
it('should return true for Chilean users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans-light-design')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'CL',
})
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
})
it('should return true for Peruvian users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans-light-design')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'PE',
})
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
})
it('should return true for US users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/plans-light-design')
opts.showLATAMBanner.should.equal(false)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'US',
})
this.SubscriptionController.plansPageLightDesign(this.req, this.res)
})
})
describe('formatCurrency data', function () {
it('return correct formatCurrency function', function (done) {
this.res.render = (page, opts) => {
@@ -646,114 +430,6 @@ describe('SubscriptionController', function () {
})
})
describe('showInrGeoBanner data', function () {
it('should return true for Indian users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/interstitial-payment')
opts.showInrGeoBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'IN',
})
this.SubscriptionController.interstitialPaymentPage(this.req, this.res)
})
it('should be false for US users', function (done) {
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'US',
})
this.res.render = (page, opts) => {
page.should.equal('subscriptions/interstitial-payment')
opts.showInrGeoBanner.should.equal(false)
done()
}
this.SubscriptionController.interstitialPaymentPage(this.req, this.res)
})
})
describe('showBrlGeoBanner data', function () {
it('should return true for Brazilian users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/interstitial-payment')
opts.showBrlGeoBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'BR',
})
this.SubscriptionController.interstitialPaymentPage(this.req, this.res)
})
it('should return false for US users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/interstitial-payment')
opts.showBrlGeoBanner.should.equal(false)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'US',
})
this.SubscriptionController.interstitialPaymentPage(this.req, this.res)
})
})
describe('showLATAMBanner', function () {
it('should return true for Mexican users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/interstitial-payment')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'MX',
})
this.SubscriptionController.interstitialPaymentPage(this.req, this.res)
})
it('should return true for Colombian users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/interstitial-payment')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'CO',
})
this.SubscriptionController.interstitialPaymentPage(this.req, this.res)
})
it('should return true for Chilean users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/interstitial-payment')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'CL',
})
this.SubscriptionController.interstitialPaymentPage(this.req, this.res)
})
it('should return true for Peruvian users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/interstitial-payment')
opts.showLATAMBanner.should.equal(true)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'PE',
})
this.SubscriptionController.interstitialPaymentPage(this.req, this.res)
})
it('should return true for US users', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/interstitial-payment')
opts.showLATAMBanner.should.equal(false)
done()
}
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'US',
})
this.SubscriptionController.interstitialPaymentPage(this.req, this.res)
})
})
it('should return correct countryCode', function (done) {
this.GeoIpLookup.promises.getCurrencyCode.resolves({
countryCode: 'MX',