update ut for validate

Signed-off-by: s00912778 <shijiakai2@huawei.com>
Change-Id: I943ad2186224def13226dd04bcf80b6331f19591
This commit is contained in:
s00912778 2024-10-22 11:22:52 +08:00
parent c30ba3fc8c
commit 899805408e
8 changed files with 35 additions and 29 deletions

View File

@ -154,11 +154,11 @@
"type": "WARN"
},
"validateForbiddenToInitViaParam": {
"message": "Property 'message' in the custom component 'Child' cannot be initialized here (forbidden to specify).",
"message": "Property 'message' in the custom component 'ValidateForbiddenToInitViaParamChild' cannot be initialized here (forbidden to specify).",
"type": "ERROR"
},
"validateMandatoryToInitViaParam": {
"message": "Property 'message' in the custom component 'Child' is missing (mandatory to specify).",
"message": "Property 'message' in the custom component 'ValidateMandatoryToInitViaParamChild' is missing (mandatory to specify).",
"type": "ERROR"
},
"validateInitDecorator": [

View File

@ -1,10 +1,13 @@
class param {
paramA1: string = ""
}
@Entry
@Component
struct Parent {
struct CheckBuilderParent {
@State label: string = 'Hello';
@Builder ABuilder($$: { paramA1: string }) {
Child({ message: $$.paramA1 })
@Builder ABuilder($$: param) {
CheckBuilderChild({ message: $$.paramA1 })
}
build() {
@ -16,7 +19,7 @@ struct Parent {
}
@Component
struct Child {
struct CheckBuilderChild {
@Link message: string
build() {

View File

@ -1,17 +1,17 @@
@Entry
@Component
struct Parent {
struct ValidateForbiddenToInitViaParamParent {
@StorageProp('111') message: string = 'Hello';
build() {
Column() {
Child({message: this.message});
ValidateForbiddenToInitViaParamChild({message: this.message});
}
}
}
@Component
struct Child {
struct ValidateForbiddenToInitViaParamChild {
@StorageProp('111') message: string = 'Hello';
build() {

View File

@ -1,17 +1,17 @@
@Entry
@Component
struct Parent {
struct ValidateIllegalInitFromParentParent {
private message: string ='Hello';
build() {
Column() {
Child({message: $message});
ValidateIllegalInitFromParentChild({message: $message});
}
}
}
@Component
struct Child {
struct ValidateIllegalInitFromParentChild {
@Link message: string;
build() {
Row() {}

View File

@ -1,18 +1,18 @@
@Entry
@Component
struct Parent {
struct ValidateInitDecoratorParent {
@State message: string ='Hello';
build() {
Column() {
Child();
ValidateInitDecoratorChild();
}
}
}
@Component
struct Child {
@Require regular_value: string
struct ValidateInitDecoratorChild {
@Require regular_value: string = "hello"
@Require @State state_value: string = "hello"
@Require @Provide provide_value: string = "hello"
@Require @Prop prop_value: string
@ -20,4 +20,4 @@ struct Child {
build() {
Row() {}
}
}
}

View File

@ -1,17 +1,17 @@
@Entry
@Component
struct Parent {
struct ValidateMandatoryToInitViaParamParent {
@State message: string ='Hello';
build() {
Column() {
Child();
ValidateMandatoryToInitViaParamChild();
}
}
}
@Component
struct Child {
struct ValidateMandatoryToInitViaParamChild {
@Link message: string
build() {
Row() {}

View File

@ -1,17 +1,17 @@
@Entry
@Component
struct Parent {
struct ValidateNonLinkWithDollarParent {
@State message: string ='Hello';
build() {
Column() {
Child({message: $message});
ValidateNonLinkWithDollarChild({message: $message});
}
}
}
@Component
struct Child {
struct ValidateNonLinkWithDollarChild {
@Prop message: string;
build() {
Row() {}

View File

@ -1,18 +1,21 @@
const gloabel_value: string = "Foo"
const obj = {
const obj: paramA = {
gloabel_value: "Foo"
}
class paramA {
gloabel_value: string = "Foo"
}
@Entry
@ComponentV2
struct validateParamTwoWayBind {
@Local local_value: string = "Foo"
obj = {
obj: paramA = {
gloabel_value: "Foo"
}
aa() {
return {
gloabel_value: "Foo"
}
} as paramA
}
bb() {
return "Foo";
@ -39,4 +42,4 @@ struct testParamChild2 {
@Param paramValue: string = "hello"
@Event $paramValue: (value: string) => void = (value: string) => {}
build() {}
}
}