@@ -11,6 +11,7 @@ import (
1111)
1212
1313func TestMagFormatMoneyWithUnit (t * testing.T ) {
14+ // Used by magCents for dashboard (input still has $ from FormatCents).
1415 tests := []struct {
1516 name string
1617 value string
@@ -31,21 +32,21 @@ func TestMagFormatMoneyWithUnit(t *testing.T) {
3132 }
3233}
3334
34- func TestMagFormatMoneyWithoutUnit (t * testing.T ) {
35+ func TestMagFormatBareMoney (t * testing.T ) {
36+ // Table cells use FormatCentsBare (no $ prefix).
3537 tests := []struct {
3638 name string
3739 value string
3840 want string
3941 }{
40- {"thousands" , "$5,234.23" , "\U0001F821 3" },
41- {"hundreds" , "$500.00" , "\U0001F821 2" },
42- {"millions" , "$1,000,000.00" , "\U0001F821 6" },
43- {"tens" , "$42.00" , "\U0001F821 1" },
44- {"single digit" , "$7.50" , "\U0001F821 0" },
45- {"sub-dollar" , "$0.50" , "\U0001F821 -1" },
46- {"zero" , "$0.00" , "\U0001F821 0" },
47- {"negative" , "-$5.00" , "-\U0001F821 0" },
48- {"negative large" , "-$12,345.00" , "-\U0001F821 4" },
42+ {"thousands" , "5,234.23" , "\U0001F821 3" },
43+ {"hundreds" , "500.00" , "\U0001F821 2" },
44+ {"millions" , "1,000,000.00" , "\U0001F821 6" },
45+ {"tens" , "42.00" , "\U0001F821 1" },
46+ {"single digit" , "7.50" , "\U0001F821 0" },
47+ {"sub-dollar" , "0.50" , "\U0001F821 -1" },
48+ {"zero" , "0.00" , "\U0001F821 0" },
49+ {"negative" , "-5.00" , "-\U0001F821 0" },
4950 }
5051 for _ , tt := range tests {
5152 t .Run (tt .name , func (t * testing.T ) {
@@ -102,18 +103,18 @@ func TestMagFormatSkipsNonNumeric(t *testing.T) {
102103 }
103104}
104105
105- func TestMagTransformCellsStripsUnit (t * testing.T ) {
106+ func TestMagTransformCells (t * testing.T ) {
106107 rows := [][]cell {
107108 {
108109 {Value : "1" , Kind : cellReadonly },
109110 {Value : "Kitchen Remodel" , Kind : cellText },
110- {Value : "$ 5,234.23" , Kind : cellMoney },
111+ {Value : "5,234.23" , Kind : cellMoney },
111112 {Value : "3" , Kind : cellDrilldown },
112113 },
113114 {
114115 {Value : "2" , Kind : cellReadonly },
115116 {Value : "Deck" , Kind : cellText },
116- {Value : "$ 100.00" , Kind : cellMoney },
117+ {Value : "100.00" , Kind : cellMoney },
117118 {Value : "0" , Kind : cellDrilldown },
118119 },
119120 }
@@ -127,7 +128,7 @@ func TestMagTransformCellsStripsUnit(t *testing.T) {
127128 assert .Equal (t , "Kitchen Remodel" , out [0 ][1 ].Value )
128129 assert .Equal (t , "Deck" , out [1 ][1 ].Value )
129130
130- // Money cells: magnitude only, no $ prefix .
131+ // Money cells: magnitude only.
131132 assert .Equal (t , "\U0001F821 3" , out [0 ][2 ].Value )
132133 assert .Equal (t , "\U0001F821 2" , out [1 ][2 ].Value )
133134
@@ -136,18 +137,18 @@ func TestMagTransformCellsStripsUnit(t *testing.T) {
136137 assert .Equal (t , "\U0001F821 0" , out [1 ][3 ].Value )
137138
138139 // Original rows are not modified.
139- assert .Equal (t , "$ 5,234.23" , rows [0 ][2 ].Value )
140+ assert .Equal (t , "5,234.23" , rows [0 ][2 ].Value )
140141}
141142
142- func TestMagAnnotateSpecs (t * testing.T ) {
143+ func TestAnnotateMoneyHeaders (t * testing.T ) {
143144 styles := DefaultStyles ()
144145 specs := []columnSpec {
145146 {Title : "Name" , Kind : cellText },
146147 {Title : "Total" , Kind : cellMoney },
147148 {Title : "Labor" , Kind : cellMoney },
148149 {Title : "ID" , Kind : cellReadonly },
149150 }
150- out := magAnnotateSpecs (specs , styles )
151+ out := annotateMoneyHeaders (specs , styles )
151152
152153 // Non-money columns unchanged.
153154 assert .Equal (t , "Name" , out [0 ].Title )
@@ -163,13 +164,13 @@ func TestMagAnnotateSpecs(t *testing.T) {
163164 assert .Equal (t , "Total" , specs [1 ].Title )
164165}
165166
166- func TestMagAnnotateSpecsPreservesLength (t * testing.T ) {
167+ func TestAnnotateMoneyHeadersPreservesLength (t * testing.T ) {
167168 styles := DefaultStyles ()
168169 specs := []columnSpec {
169170 {Title : "A" , Kind : cellText },
170171 {Title : "B" , Kind : cellMoney },
171172 }
172- out := magAnnotateSpecs (specs , styles )
173+ out := annotateMoneyHeaders (specs , styles )
173174 require .Len (t , out , 2 )
174175}
175176
0 commit comments