-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a8ca84
commit db72a90
Showing
6 changed files
with
126 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
test/forms/ConsolidatedOrIndividualExpensesFormProviderSpec.scala
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
test/forms/foreign/expenses/ConsolidatedOrIndividualExpensesFormProviderSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package forms.foreign.expenses | ||
|
||
import forms.behaviours.OptionFieldBehaviours | ||
import models.ConsolidatedOrIndividualExpenses | ||
import play.api.data.FormError | ||
|
||
import scala.collection.immutable.ArraySeq | ||
|
||
class ConsolidatedOrIndividualExpensesFormProviderSpec extends OptionFieldBehaviours { | ||
|
||
val requiredKey = "consolidatedOrIndividualExpenses.error.required.agent" | ||
val invalidKey = "error.boolean" | ||
|
||
val form = new ConsolidatedOrIndividualExpensesFormProvider()("agent") | ||
|
||
".consolidatedExpensesAmount" - { | ||
"consolidatedOrIndividualExpenses" - { | ||
"and an amount is entered, should successfully bind" in { | ||
val boundForm = form.bind(Map("consolidatedOrIndividualExpenses" -> "true", "consolidatedExpensesAmount" -> "4534.65")) | ||
boundForm.value.value mustBe ConsolidatedOrIndividualExpenses(consolidatedOrIndividualExpensesYesNo = true, Some(4534.65)) | ||
boundForm.errors mustBe empty | ||
} | ||
|
||
"and no amount is entered, should fail to bind" in { | ||
val boundForm = form.bind(Map("consolidatedOrIndividualExpenses" -> "true")) | ||
boundForm.errors must contain(FormError("consolidatedExpensesAmount", "consolidatedOrIndividualExpenses.amount.error.required.agent")) | ||
} | ||
|
||
"and a non numeric value is entered then should fail to bind" in { | ||
val boundForm = form.bind(Map("consolidatedOrIndividualExpenses" -> "true", "consolidatedExpensesAmount" -> "non-numeric-value")) | ||
boundForm.errors must contain(FormError("consolidatedExpensesAmount", "consolidatedOrIndividualExpenses.amount.error.nonNumerical")) | ||
} | ||
|
||
|
||
"and an amount is entered that has more than 2 decimal places then it should fail to bind" in { | ||
val boundForm = form.bind(Map("consolidatedOrIndividualExpenses" -> "true", "consolidatedExpensesAmount" -> "4534.6545")) | ||
boundForm.errors must contain(FormError("consolidatedExpensesAmount", "consolidatedOrIndividualExpenses.amount.error.twoDecimalPlaces.agent")) | ||
} | ||
|
||
|
||
"and an amount is entered that is out of range then should fail to bind" in { | ||
val boundForm = form.bind(Map("consolidatedOrIndividualExpenses" -> "true", "consolidatedExpensesAmount" -> "4533455353453534543534")) | ||
boundForm.errors must contain( | ||
FormError( | ||
"consolidatedExpensesAmount", | ||
"consolidatedOrIndividualExpenses.amount.error.outOfRange", | ||
ArraySeq(0, 1000000000) | ||
) | ||
) | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.