問題文
A ferry operator's booking component decides the cancellation fee in its JavaScript, reading three fields and applying four rules. The team has no JavaScript test setup and the finance department demands evidence that the rules are right. Where should the rules live?
選択肢
- In a formula field on the booking object, because a declarative calculation needs no test of its own and a component can then simply display the field that the platform maintains.
- In the component, because keeping the calculation next to the display avoids a server round trip for every fee that has to be recalculated there.
- In Apex, and the component should then call it through the wire adapter for every keystroke so the fee is always current, which also means the calculation is covered by the Apex tests that finance wants to see.
- In Apex, where the platform's own test framework can assert each rule and the coverage requirement applies, leaving the component to display what the server returns, because Apex is the layer the platform's own test framework can exercise directly.