From 3ef0db7f8cef586273d3d4349955086dd9dc6217 Mon Sep 17 00:00:00 2001 From: Ivan Josipovic <9521987+IvanJosipovic@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:28:53 -0700 Subject: [PATCH] feat: support boolean --- .../CodeGenerationTests.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/BlazorInteropGenerator.Tests/CodeGenerationTests.cs b/tests/BlazorInteropGenerator.Tests/CodeGenerationTests.cs index 26db71e..377a673 100644 --- a/tests/BlazorInteropGenerator.Tests/CodeGenerationTests.cs +++ b/tests/BlazorInteropGenerator.Tests/CodeGenerationTests.cs @@ -178,6 +178,38 @@ export interface SomeType { prop1.AccessorList.Accessors[1].Kind().Should().Be(SyntaxKind.SetAccessorDeclaration); } + [Fact] + public void InterfacePropertyBoolean() + { + var tsd = """ + export interface SomeType { + prop1: boolean; + } + """; + + var syntaxFactory = Generator.GenerateObjects(tsd, "SomeType", TSDParser.Enums.SyntaxKind.InterfaceDeclaration, "Test"); + + var code = syntaxFactory + .NormalizeWhitespace() + .ToFullString(); + + syntaxFactory.Members.Count.Should().Be(1); + var @interface = (syntaxFactory.Members[0] as NamespaceDeclarationSyntax).Members[0] as InterfaceDeclarationSyntax; + + var prop1 = @interface.Members[0] as PropertyDeclarationSyntax; + + prop1.Modifiers.Count.Should().Be(1); + prop1.Modifiers[0].Value.Should().Be("public"); + + prop1.Type.As().Keyword.Text.Should().Be("bool"); + + prop1.Identifier.Text.Should().Be("prop1"); + + prop1.AccessorList.Accessors.Count.Should().Be(2); + prop1.AccessorList.Accessors[0].Kind().Should().Be(SyntaxKind.GetAccessorDeclaration); + prop1.AccessorList.Accessors[1].Kind().Should().Be(SyntaxKind.SetAccessorDeclaration); + } + [Fact] public void InterfaceMethodVoid() {