Skip to content

Commit

Permalink
test: added snapshot test for watchlist
Browse files Browse the repository at this point in the history
  • Loading branch information
achannarasappa committed Apr 5, 2021
1 parent 36ae53a commit b44de9e
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 257 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
STOCK1Day Range: 90.00 - 120.00 Prev. Close: 100.00 105.00
Stock 1 Inc. (gain) 52wk Range: 0.00 - 0.00 Open: 110.005.00 (5.00%)
Real-Time
STOCK2Day Range: 90.00 - 120.00 Prev. Close: 100.00 95.00
Stock 2 Inc. (loss) 52wk Range: 0.00 - 150.00 Open: 110.00-5.00 (-5.00%)
Real-Time
STOCK3Day Range: 90.00 - 120.00 Prev. Close: 100.00 105.00
Stock 3 Inc. (gain, 52wk Range: 0.00 - 150.00 Open: 110.005.00 (5.00%)
Real-Time
STOCK4Day Range: 90.00 - 120.00 Prev. Close: 100.00 Quantity: 100.00 105.00 (0.00%) 105.00
Stock 4 Inc. (positi 52wk Range: 0.00 - 150.00 Open: 110.00 Avg. Cost: 0.0055.00 (110.00%) ↑ 5.00 (5.00%)
Real-Time
STOCK5Day Range: 90.00 - 120.00 Prev. Close: 100.00 Quantity: 100.00 105.00 (0.00%) 105.00
Stock 5 Inc. (positi 52wk Range: 0.00 - 150.00 Open: 110.00 Avg. Cost: 0.00-45.00 (-30.00%) ↑ 5.00 (5.00%)
Real-Time
STOCK6Day Range: 90.00 - 120.00 Prev. Close: 100.00 Quantity: 100.00 95.00 (0.00%) 95.00
Stock 6 Inc. (positi 52wk Range: 0.00 - 150.00 Open: 110.00 Avg. Cost: 0.00-55.00 (-36.67%) ↓ -5.00 (-5.00%)
Real-Time
STOCK7Day Range: 90.00 - 120.00 Prev. Close: 100.00 Quantity: 100.00 95.00 (0.00%) 95.00
Stock 7 Inc. (positi 52wk Range: 0.00 - 0.00 Open: 110.00 Avg. Cost: 0.0045.00 (90.00%) ↓ -5.00 (-5.00%)
Real-Time
STOCK8 Day Range: 90.00 - 120.00 Prev. Close: 100.00 Quantity: 100.00 95.00 (0.00%) 95.00
Stock 8 Inc. (positi 52wk Range: 0.00 - 0.00 Open: 110.00 Avg. Cost: 0.0045.00 (90.00%) 0.00 (0.00%)
Real-Time
10 changes: 9 additions & 1 deletion internal/ui/component/watchlist/watchlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,15 @@ func getCellWidths(quotes []Quote, positions map[string]Position) CellWidths {
cellMaxWidths := CellWidths{}

for _, quote := range quotes {
quoteLength := len(ConvertFloatToString(quote.FiftyTwoWeekHigh, quote.IsVariablePrecision))
var quoteLength int

if quote.FiftyTwoWeekHigh == 0.0 {
quoteLength = len(ConvertFloatToString(quote.Price, quote.IsVariablePrecision))
}

if quote.FiftyTwoWeekHigh != 0.0 {
quoteLength = len(ConvertFloatToString(quote.FiftyTwoWeekHigh, quote.IsVariablePrecision))
}

if quoteLength > cellMaxWidths.quoteLength {
cellMaxWidths.quoteLength = quoteLength
Expand Down
Loading

0 comments on commit b44de9e

Please sign in to comment.