Skip to content
Snippets Groups Projects
Select Git revision
  • 99a358c775aab5acaa28baba7d275fa63c3396b4
  • main default protected
  • trading_hours
  • refactor_trading_hours
  • audit_cleaning_cater_for_non_struct_fields
  • remove-info-logs
  • sl-refactor
  • 18-use-scan-for-param-values
  • 17-order-search-results
  • 4-simplify-framework-2
  • 1-http-error
  • v1.297.0
  • v1.296.0
  • v1.295.0
  • v1.294.0
  • v1.293.0
  • v1.292.0
  • v1.291.0
  • v1.290.0
  • v1.289.0
  • v1.288.0
  • v1.287.0
  • v1.286.0
  • v1.285.0
  • v1.284.0
  • v1.283.0
  • v1.282.0
  • v1.281.0
  • v1.280.0
  • v1.279.0
  • v1.278.0
31 results

address_utils_test.go

Blame
  • address_utils_test.go 1.66 KiB
    package address_utils
    
    import (
    	"fmt"
    	"testing"
    )
    
    func TestCleanProvince(t *testing.T) {
    	zone := "Wes KaaP"
    	country := "South Africa"
    	cleanCountry, cleanZone := CleanZone(&country, &zone)
    
    	fmt.Printf("%s, %s converted to %s, %s\n", zone, country, *cleanZone, *cleanCountry)
    }
    
    func TestIsProvince(t *testing.T) {
    	type args struct {
    		address string
    	}
    	tests := []struct {
    		name string
    		args args
    		want bool
    	}{{
    		name: "IsProvince",
    		args: args{address: "North West, South Africa"},
    		want: true,
    	}, {
    		name: "IsProvince2",
    		args: args{address: "KwaZulu Natal, South Africa"},
    		want: true,
    	}, {
    		name: "IsProvince3",
    		args: args{address: "KZN, South Africa"},
    		want: true,
    	}, {
    		name: "IsNotProvince",
    		args: args{address: "22 Kruis Street, Potchefstroom, Potchefstroom, 2531, GP, ZA"},
    		want: false,
    	},
    	}
    	for _, tt := range tests {
    		t.Run(tt.name, func(t *testing.T) {
    			if got := IsProvince(tt.args.address); got != tt.want {
    				t.Errorf("IsProvince() = %v, want %v", got, tt.want)
    			}
    		})
    	}
    }
    
    func TestZoneDisplayName(t *testing.T) {
    	type args struct {
    		zone string
    	}
    	tests := []struct {
    		name string
    		args args
    		want string
    	}{{
    		name: "IsValidZone",
    		args: args{zone: "LP"},
    		want: "Limpopo",
    	}, {
    		name: "IsValidZone2",
    		args: args{zone: "KZN"},
    		want: "KwaZulu-Natal",
    	}, {
    		name: "IsNotValidZone",
    		args: args{zone: "invalidF"},
    		want: "invalidF",
    	}, {
    		name: "IsNotValidZone 2",
    		args: args{zone: "NP"},
    		want: "NP",
    	},
    	}
    	for _, tt := range tests {
    		t.Run(tt.name, func(t *testing.T) {
    			if got := GetZoneDisplayName(tt.args.zone); got != tt.want {
    				t.Errorf("GetZoneDisplayName() = %v, want %v", got, tt.want)
    			}
    		})
    	}
    }