func TestEncodeURIComponent(t *testing.T) {
	encodeEscapeTests := map[string]string{
		";,/?:@&=+$":  "%3B%2C%2F%3F%3A%40%26%3D%2B%24",
		"-_.!~*'()":   "-_.!~*'()",
		"#":           "%23",
		"ABC abc 123": "ABC%20abc%20123",
	}
	encodeURIComponent := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
		str := args[0].String()
		e := ""
		for _, r := range str {
			switch {
			case strings.ContainsRune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~*'()", r):
				e += string(r)
			default:
				e += "%" + strings.ToUpper(strconv.FormatInt(int64(r), 16))
			}
		}
		return e
	})
	defer encodeURIComponent.Release()
	for text, want := range encodeEscapeTests {
		dom := DOM{js.ValueOf(map[string]interface{}{
			"encodeURIComponent": encodeURIComponent,
		})}
		got := dom.EncodeURIComponent(text)
		if want != got {
			t.Errorf("did not encode properly\nwanted: %v\ngot:    %v", want, got)
		}
	}
}
// TestEncodeURIComponent ensures encodeURIComponent is called.
// tests copied from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
TestEncodeURIComponent ensures encodeURIComponent is called.
// TestEncodeURIComponent ensures encodeURIComponent is called . // tests copied from https : // developer . mozilla . org / en - US / docs / Web / JavaScript / Reference / Global_Objects / encodeURIComponent
func TestEncodeURIComponent(t *testing.T) {
	encodeEscapeTests := map[string]string{
		";,/?:@&=+$":  "%3B%2C%2F%3F%3A%40%26%3D%2B%24",
		"-_.!~*'()":   "-_.!~*'()",
		"#":           "%23",
		"ABC abc 123": "ABC%20abc%20123",
	}
	encodeURIComponent := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
		str := args[0].String()
		e := ""
		for _, r := range str {
			switch {
			case strings.ContainsRune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~*'()", r):
				e += string(r)
			default:
				e += "%" + strings.ToUpper(strconv.FormatInt(int64(r), 16))
			}
		}
		return e
	})
	defer encodeURIComponent.Release()
	for text, want := range encodeEscapeTests {
		dom := DOM{js.ValueOf(map[string]interface{}{
			"encodeURIComponent": encodeURIComponent,
		})}
		got := dom.EncodeURIComponent(text)
		if want != got {
			t.Errorf("did not encode properly\nwanted: %v\ngot:    %v", want, got)
		}
	}
}
func TestEncodeURIComponent ( t * testing . T ) { encodeEscapeTests := map [ string ] string { " " : " " , " " : " " , " " : " " , " " : " " , } encodeURIComponent := js . FuncOf ( func ( this js . Value , args [ ] js . Value ) interface { } { str := args [ 0 ] . String ( ) e := " " for _ , r := range str { switch { case strings . ContainsRune ( " " , r ) : e += string ( r ) default : e += " " + strings . ToUpper ( strconv . FormatInt ( int64 ( r ) , 16 ) ) } } return e } ) defer encodeURIComponent . Release ( ) for text , want := range encodeEscapeTests { dom := DOM { js . ValueOf ( map [ string ] interface { } { " " : encodeURIComponent , } ) } got := dom . EncodeURIComponent ( text ) if want != got { t . Errorf ( " \n \n " , want , got ) } } }
TestEncodeURIComponent ensures encodeURIComponent is called.
TestEncodeURIComponent ensures encodeURIComponent is called .