You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider setting up `RuleTester`'s static properties in a preloaded module using the [`--import`](https://nodejs.org/api/cli.html#--importmodule) or [`--require`](https://nodejs.org/api/cli.html#-r---require-module) flag:
@@ -812,6 +851,19 @@ export class RuleTester extends TestFramework {
812
851
error.messageId,
813
852
`messageId '${message.messageId}' does not match expected messageId '${error.messageId}'.`,
814
853
);
854
+
855
+
constunsubstitutedPlaceholders=
856
+
getUnsubstitutedMessagePlaceholders(
857
+
message.message,
858
+
rule.meta.messages[message.messageId],
859
+
error.data,
860
+
);
861
+
862
+
assert.ok(
863
+
unsubstitutedPlaceholders.length===0,
864
+
`The reported message has ${unsubstitutedPlaceholders.length>1 ? `unsubstituted placeholders: ${unsubstitutedPlaceholders.map(name=>`'${name}'`).join(', ')}` : `an unsubstituted placeholder '${unsubstitutedPlaceholders[0]}'`}. Please provide the missing ${unsubstitutedPlaceholders.length>1 ? 'values' : 'value'} via the 'data' property in the context.report() call.`,
865
+
);
866
+
815
867
if(hasOwnProperty(error,'data')){
816
868
/*
817
869
* if data was provided, then directly compare the returned message to a synthetic
@@ -957,6 +1009,19 @@ export class RuleTester extends TestFramework {
957
1009
expectedSuggestion.messageId,
958
1010
`${suggestionPrefix} messageId should be '${expectedSuggestion.messageId}' but got '${actualSuggestion.messageId}' instead.`,
959
1011
);
1012
+
1013
+
constunsubstitutedPlaceholders=
1014
+
getUnsubstitutedMessagePlaceholders(
1015
+
actualSuggestion.desc,
1016
+
rule.meta.messages[expectedSuggestion.messageId],
1017
+
expectedSuggestion.data,
1018
+
);
1019
+
1020
+
assert.ok(
1021
+
unsubstitutedPlaceholders.length===0,
1022
+
`The message of the suggestion has ${unsubstitutedPlaceholders.length>1 ? `unsubstituted placeholders: ${unsubstitutedPlaceholders.map(name=>`'${name}'`).join(', ')}` : `an unsubstituted placeholder '${unsubstitutedPlaceholders[0]}'`}. Please provide the missing ${unsubstitutedPlaceholders.length>1 ? 'values' : 'value'} via the 'data' property for the suggestion in the context.report() call.`,
},"The reported message has an unsubstituted placeholder 'name'. Please provide the missing value via the 'data' property in the context.report() call.");
1696
+
});
1697
+
1698
+
it("should throw if the message has a single unsubstituted placeholders when data is specified",()=>{
},"The reported message has unsubstituted placeholders: 'type', 'name'. Please provide the missing values via the 'data' property in the context.report() call.");
1714
+
});
1715
+
1716
+
it("should not throw if the data in the message contains placeholders not present in the raw message",()=>{
},"The reported message has an unsubstituted placeholder 'name'. Please provide the missing value via the 'data' property in the context.report() call.");
1730
+
});
1731
+
1732
+
it("should not throw if the data in the message contains the same placeholder and data is specified",()=>{
},"The message of the suggestion has an unsubstituted placeholder 'newName'. Please provide the missing value via the 'data' property for the suggestion in the context.report() call.");
1930
+
});
1931
+
1932
+
it("should fail with a single missing data placeholder when data is specified",()=>{
},"The message of the suggestion has an unsubstituted placeholder 'newName'. Please provide the missing value via the 'data' property for the suggestion in the context.report() call.");
1949
+
});
1950
+
1951
+
it("should fail with multiple missing data placeholders when data is not specified",()=>{
},"The message of the suggestion has unsubstituted placeholders: 'currentName', 'newName'. Please provide the missing values via the 'data' property for the suggestion in the context.report() call.");
1967
+
});
1968
+
1857
1969
1858
1970
it("should pass when tested using empty suggestion test objects if the array length is correct",()=>{
0 commit comments