@@ -97,61 +97,60 @@ TestCase {
9797 compare (optionsModel .displayUnit , 0 )
9898 }
9999
100- // Mirrors the balance prefix expression in WalletBadge.qml.
100+ // Mirrors the balance suffix expression in WalletBadge.qml.
101+ // balanceSatoshi=1000 → plural "sats"; balanceSatoshi=1 → singular "sat".
101102 Component {
102- id: balancePrefixComponent
103+ id: balanceSuffixComponent
103104 Text {
104105 property string balance: " 1 000"
105- text: (optionsModel .displayUnit === 1 ? " s" : " ₿" ) + " " + balance
106+ property var balanceSatoshi: 1000
107+ text: balance + " " + (optionsModel .displayUnit === 1 ? (balanceSatoshi === 1 ? " sat" : " sats" ) : " ₿" )
106108 }
107109 }
108110
109- function test_walletBadge_prefix_is_s_in_sat_mode () {
111+ function test_walletBadge_suffix_is_sats_in_sat_mode () {
110112 optionsModel .displayUnit = 1
111- const obj = createTemporaryObject (balancePrefixComponent , this )
113+ const obj = createTemporaryObject (balanceSuffixComponent , this )
112114 verify (obj !== null )
113- compare (obj .text , " s 1 000" )
115+ compare (obj .text , " 1 000 sats " )
114116 optionsModel .displayUnit = 0
115117 }
116118
117- function test_walletBadge_prefix_is_btc_symbol_in_btc_mode () {
119+ function test_walletBadge_suffix_is_sat_singular_in_sat_mode () {
120+ optionsModel .displayUnit = 1
121+ const obj = createTemporaryObject (balanceSuffixComponent, this )
122+ verify (obj !== null )
123+ obj .balanceSatoshi = 1
124+ compare (obj .text , " 1 000 sat" )
118125 optionsModel .displayUnit = 0
119- const obj = createTemporaryObject (balancePrefixComponent, this )
126+ }
127+
128+ function test_walletBadge_suffix_is_btc_symbol_in_btc_mode () {
129+ optionsModel .displayUnit = 0
130+ const obj = createTemporaryObject (balanceSuffixComponent, this )
120131 verify (obj !== null )
121- compare (obj .text , " ₿ 1 000" )
132+ compare (obj .text , " 1 000 ₿ " )
122133 }
123134
124- // Mirrors the Loader + Component pattern in BitcoinAmountInputField.qml,
125- // Send.qml, and RequestPayment.qml.
126- Component {
127- id: unitLabelComponent
128- Item {
129- id: wrapper
130- property int unit: 0
131- Loader {
132- objectName: " unitLabelLoader"
133- sourceComponent: wrapper .unit === 1 ? satComponent : btcComponent
134- }
135- Component { id: btcComponent; Text { text: " ₿" } }
136- Component { id: satComponent; Text { text: " s" } }
137- }
135+ // Tests displayUnitLabelForAmount pluralization logic.
136+ function test_displayUnitLabelForAmount_singular_in_sat_mode () {
137+ optionsModel .displayUnit = 1
138+ compare (optionsModel .displayUnitLabelForAmount (1 ), " sat" )
139+ compare (optionsModel .displayUnitLabelForAmount (- 1 ), " sat" )
140+ optionsModel .displayUnit = 0
138141 }
139142
140- function test_unitLabel_shows_s_in_sat_mode () {
141- const obj = createTemporaryObject (unitLabelComponent, this )
142- obj .unit = 1
143- waitForRendering (obj)
144- const loader = findChild (obj, " unitLabelLoader" )
145- verify (loader .item !== null )
146- compare (loader .item .text , " s" )
143+ function test_displayUnitLabelForAmount_plural_in_sat_mode () {
144+ optionsModel .displayUnit = 1
145+ compare (optionsModel .displayUnitLabelForAmount (0 ), " sats" )
146+ compare (optionsModel .displayUnitLabelForAmount (2 ), " sats" )
147+ compare (optionsModel .displayUnitLabelForAmount (1000 ), " sats" )
148+ optionsModel .displayUnit = 0
147149 }
148150
149- function test_unitLabel_shows_btc_symbol_in_btc_mode () {
150- const obj = createTemporaryObject (unitLabelComponent, this )
151- obj .unit = 0
152- waitForRendering (obj)
153- const loader = findChild (obj, " unitLabelLoader" )
154- verify (loader .item !== null )
155- compare (loader .item .text , " ₿" )
151+ function test_displayUnitLabelForAmount_btc_symbol_in_btc_mode () {
152+ optionsModel .displayUnit = 0
153+ compare (optionsModel .displayUnitLabelForAmount (1 ), " ₿" )
154+ compare (optionsModel .displayUnitLabelForAmount (1000 ), " ₿" )
156155 }
157156}
0 commit comments