5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 03:01:45 +08:00

Special chars bindings unit tests (#3485)

* JSON fields that start with special characters generate wrong typescript bindings

* Update changelong
This commit is contained in:
Gjergji Ramku 2024-05-17 10:32:54 +02:00 committed by GitHub
parent d4dabc1289
commit a7a4341f79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 0 deletions

View File

@ -48,6 +48,7 @@ func TestBindings_GenerateModels(t *testing.T) {
AnonymousSubStructMultiLevelTest,
GeneratedJsEntityWithNestedStructTest,
EntityWithDiffNamespaces,
SpecialCharacterFieldTest,
}
testLogger := &logger.Logger{}

View File

@ -0,0 +1,32 @@
package binding_test
type SpecialCharacterField struct {
ID string `json:"@ID,omitempty"`
}
func (s SpecialCharacterField) Get() SpecialCharacterField {
return s
}
var SpecialCharacterFieldTest = BindingTest{
name: "SpecialCharacterField",
structs: []interface{}{
&SpecialCharacterField{},
},
exemptions: nil,
shouldError: false,
want: `
export namespace binding_test {
export class SpecialCharacterField {
"@ID"?: string;
static createFrom(source: any = {}) {
return new SpecialCharacterField(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this["@ID"] = source["@ID"];
}
}
}
`,
}

View File

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Support for compiling with `libwebkit2gtk-4.1` instead of `4.0` to support latest Ubuntu release by [atterpac](https://github.com/atterpac) in [#3465](https://github.com/wailsapp/wails/pull/3465)
- Unit test for fix [#3476](https://github.com/wailsapp/wails/pull/3476) by [gjergj](https://github.com/Gjergj) in [#3485](https://github.com/wailsapp/wails/pull/3485)
### Changed
- Updated several broken links in the "How Does It Work?" page on the website. Changed by [@oguz-yilmaz](https://github.com/oguz-yilmaz) in [PR #3469](https://github.com/wailsapp/wails/pull/3469)