const SandboxedModule = require('sandboxed-module') const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Subscription/SubscriptionHelper' const plans = { expensive: { planCode: 'expensive', price: 15, }, cheaper: { planCode: 'cheaper', price: 5, }, alsoCheap: { plancode: 'also-cheap', price: 5, }, bad: {}, } describe('SubscriptionHelper', function () { beforeEach(function () { this.SubscriptionHelper = SandboxedModule.require(modulePath) }) describe('shouldPlanChangeAtTermEnd', function () { it('should return true if the new plan is less expensive', function () { const changeAtTermEnd = this.SubscriptionHelper.shouldPlanChangeAtTermEnd( plans.expensive, plans.cheaper ) expect(changeAtTermEnd).to.be.true }) it('should return false if the new plan is more exepensive', function () { const changeAtTermEnd = this.SubscriptionHelper.shouldPlanChangeAtTermEnd( plans.cheaper, plans.expensive ) expect(changeAtTermEnd).to.be.false }) it('should return false if the new plan is the same price', function () { const changeAtTermEnd = this.SubscriptionHelper.shouldPlanChangeAtTermEnd( plans.cheaper, plans.alsoCheap ) expect(changeAtTermEnd).to.be.false }) }) })