5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 06:20:48 +08:00
wails/v2/internal/binding/binding_test/binding_escapedname_test.go
JulioDRF 40e326a708
Fix binding generation special cases (#1902)
* Make binding.go easier to test

* Fix non-deterministic namespace order for bindings

* Add binding tests

* Fix nested import structs, non-string map keys, and escape invalid variable names

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2022-10-01 15:49:51 +10:00

33 lines
600 B
Go

package binding_test
type EscapedName struct {
Name string `json:"n.a.m.e"`
}
func (s EscapedName) Get() EscapedName {
return s
}
var EscapedNameTest = BindingTest{
name: "EscapedName",
structs: []interface{}{
&EscapedName{},
},
exemptions: nil,
shouldError: false,
want: `
export namespace binding_test {
export class EscapedName {
"n.a.m.e": string;
static createFrom(source: any = {}) {
return new EscapedName(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this["n.a.m.e"] = source["n.a.m.e"];
}
}
}
`,
}