mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
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>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package binding_test
|
||||
|
||||
type NonStringMapKey struct {
|
||||
NumberMap map[uint]any `json:"numberMap"`
|
||||
}
|
||||
|
||||
func (s NonStringMapKey) Get() NonStringMapKey {
|
||||
return s
|
||||
}
|
||||
|
||||
var NonStringMapKeyTest = BindingTest{
|
||||
name: "NonStringMapKey",
|
||||
structs: []interface{}{
|
||||
&NonStringMapKey{},
|
||||
},
|
||||
exemptions: nil,
|
||||
shouldError: false,
|
||||
want: `
|
||||
export namespace binding_test {
|
||||
export class NonStringMapKey {
|
||||
numberMap: {[key: number]: any};
|
||||
static createFrom(source: any = {}) {
|
||||
return new NonStringMapKey(source);
|
||||
}
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.numberMap = source["numberMap"];
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
}
|
||||
Reference in New Issue
Block a user