Files
scraper/utils/utils_test.go
T
2020-03-03 17:15:16 +11:00

93 lines
1.2 KiB
Go

package utils
import (
"testing"
)
func Test_toMoney(t *testing.T) {
type args struct {
priceString string
}
tests := []struct {
name string
args args
want int
}{
{
"$1.5m",
args{
priceString: "$1.5m",
},
1500000,
},
{
"$390k",
args{
priceString: "$390k",
},
390000,
},
{
"$2.01m max bi",
args{
priceString: `$2.01m max bi\`,
},
2010000,
},
{
`$890k max bi\`,
args{
priceString: `$890k max bi\`,
},
890000,
},
{
"empty string",
args{
priceString: "",
},
0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ToMoney(tt.args.priceString); got != tt.want {
t.Errorf("toMoney() = %v, want %v", got, tt.want)
}
})
}
}
func Test_toBed(t *testing.T) {
type args struct {
bedsString string
}
tests := []struct {
name string
args args
want int
}{
{
"2 beds",
args{
"2 beds",
},
2,
},
{
"1 bed",
args{
"1 bed",
},
1,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ToBeds(tt.args.bedsString); got != tt.want {
t.Errorf("toBed() = %v, want %v", got, tt.want)
}
})
}
}