Skip to content

Commit

Permalink
Merge branch 'strip-dollar-sign' into ep-upgrade-stage
Browse files Browse the repository at this point in the history
  • Loading branch information
wrandall22 committed Oct 25, 2023
2 parents f3c66ae + 480eebb commit bb6392c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,7 @@ class ProductConfigFormController {
const data = this.omitIrrelevantData(this.itemConfig)
const comment = data.DONATION_SERVICES_COMMENTS
const isTestingTransaction = comment ? comment.toLowerCase().includes('test') : false
const transformedAmount = this.transformAmountIfNecessary(data.AMOUNT)
if (transformedAmount === 'error') {
this.submittingGift = false
this.errorSavingGeneric = true
this.onStateChange({ state: 'errorSubmitting' })
return
}
data.AMOUNT = transformedAmount
data.AMOUNT = this.transformAmountIfNecessary(data.AMOUNT)
this.brandedAnalyticsFactory.saveTestingTransaction(isTestingTransaction)
this.analyticsFactory.saveTestingTransaction(this.productData, isTestingTransaction)

Expand Down Expand Up @@ -373,10 +366,9 @@ class ProductConfigFormController {
let transformedAmount = amount
if (!angular.isNumber(amount)) {
transformedAmount = amount.replace('$', '')
transformedAmount = transformedAmount.replace(',', '')
transformedAmount = parseFloat(transformedAmount)
if (isNaN(transformedAmount)) {
return 'error'
return amount
}
}
return transformedAmount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,17 +728,6 @@ describe('product config form component', function () {
expect($ctrl.errorAlreadyInCart).toEqual(false)
expect($ctrl.errorSavingGeneric).toEqual(false)
})

it('should fail if the amount is invalid', () => {
$ctrl.itemConfig.AMOUNT = 'test'
$ctrl.itemConfigForm.$dirty = true
$ctrl.saveGiftToCart()

expect($ctrl.submittingGift).toEqual(false)
expect($ctrl.onStateChange).toHaveBeenCalledWith({ state: 'errorSubmitting' })
expect($ctrl.errorAlreadyInCart).toEqual(false)
expect($ctrl.errorSavingGeneric).toEqual(true)
})
}
})

Expand Down Expand Up @@ -803,14 +792,9 @@ describe('product config form component', function () {
expect($ctrl.transformAmountIfNecessary(amount)).toEqual(50)
})

it('should remove the comma', () => {
const amount = '1,000'
expect($ctrl.transformAmountIfNecessary(amount)).toEqual(1000)
})

it('should return an error', () => {
it('should pass through the original amount', () => {
const amount = 'test'
expect($ctrl.transformAmountIfNecessary(amount)).toEqual('error')
expect($ctrl.transformAmountIfNecessary(amount)).toEqual('test')
})
})
})

0 comments on commit bb6392c

Please sign in to comment.