mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 18:10:48 +08:00

* 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>
33 lines
583 B
Go
33 lines
583 B
Go
package binding_test
|
|
|
|
type SingleField struct {
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func (s SingleField) Get() SingleField {
|
|
return s
|
|
}
|
|
|
|
var SingleFieldTest = BindingTest{
|
|
name: "SingleField",
|
|
structs: []interface{}{
|
|
&SingleField{},
|
|
},
|
|
exemptions: nil,
|
|
shouldError: false,
|
|
want: `
|
|
export namespace binding_test {
|
|
export class SingleField {
|
|
name: string;
|
|
static createFrom(source: any = {}) {
|
|
return new SingleField(source);
|
|
}
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.name = source["name"];
|
|
}
|
|
}
|
|
}
|
|
`,
|
|
}
|