From 0adf54ff8154c2cf0ebd167efaae5b06f2b86388 Mon Sep 17 00:00:00 2001 From: Robert Eldredge Date: Thu, 26 Aug 2021 16:27:58 -0400 Subject: [PATCH] Persist Premium Code --- .../step-1/branded-checkout-step-1.component.js | 11 +++++++++-- .../branded/step-1/branded-checkout-step-1.spec.js | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app/branded/step-1/branded-checkout-step-1.component.js b/src/app/branded/step-1/branded-checkout-step-1.component.js index 41500fa06..b6eb7884c 100644 --- a/src/app/branded/step-1/branded-checkout-step-1.component.js +++ b/src/app/branded/step-1/branded-checkout-step-1.component.js @@ -27,11 +27,11 @@ class BrandedCheckoutStep1Controller { this.resetSubmission() this.initItemConfig() this.initCart() - - this.premiumSelected = false } initItemConfig () { + this.defaultItemConfig = angular.copy(this.itemConfig) + this.itemConfig = {} this.itemConfig['campaign-code'] = this.campaignCode if (this.itemConfig['campaign-code'] && @@ -60,6 +60,13 @@ class BrandedCheckoutStep1Controller { } this.itemConfig['recurring-day-of-month'] = this.day this.itemConfig.frequency = this.frequency + + this.premiumSelected = false + + if (this.defaultItemConfig && this.defaultItemConfig['premium-code']) { + this.itemConfig['premium-code'] = this.defaultItemConfig['premium-code'] + this.premiumSelected = true + } } initCart () { diff --git a/src/app/branded/step-1/branded-checkout-step-1.spec.js b/src/app/branded/step-1/branded-checkout-step-1.spec.js index e81faa748..40668d45b 100644 --- a/src/app/branded/step-1/branded-checkout-step-1.spec.js +++ b/src/app/branded/step-1/branded-checkout-step-1.spec.js @@ -84,6 +84,12 @@ describe('branded checkout step 1', () => { $ctrl.initItemConfig() expect($ctrl.itemConfig['campaign-code']).toEqual('') }) + + it('should persist premium-code in item config', () => { + $ctrl.itemConfig = { 'premium-code': '112233' } + $ctrl.initItemConfig() + expect($ctrl.itemConfig['premium-code']).toEqual('112233') + }) }) describe('initCart', () => {