Require read-only testers for matchers util (#39009)

This commit is contained in:
Alex Povar
2019-10-09 12:29:31 -07:00
committed by Armando Aguirre
parent 94751f2fda
commit b7d7813c5d
4 changed files with 12 additions and 12 deletions
+3 -3
View File
@@ -327,7 +327,7 @@ declare namespace jasmine {
negativeCompare?(actual: any, ...expected: any[]): CustomMatcherResult;
}
type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]) => CustomMatcher;
type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: ReadonlyArray<CustomEqualityTester>) => CustomMatcher;
interface CustomMatcherFactories {
[index: string]: CustomMatcherFactory;
@@ -339,8 +339,8 @@ declare namespace jasmine {
}
interface MatchersUtil {
equals(a: any, b: any, customTesters?: CustomEqualityTester[]): boolean;
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: CustomEqualityTester[]): boolean;
equals(a: any, b: any, customTesters?: ReadonlyArray<CustomEqualityTester>): boolean;
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: ReadonlyArray<CustomEqualityTester>): boolean;
buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string;
}
+3 -3
View File
@@ -917,10 +917,10 @@ describe("jasmine.any", () => {
});
describe('custom asymmetry', function() {
const tester = {
asymmetricMatch: (actual: string) => {
const tester: jasmine.AsymmetricMatcher<string> = {
asymmetricMatch: (actual: string, customTesters) => {
const secondValue = actual.split(',')[1];
return secondValue === 'bar';
return jasmine.matchersUtil.equals(secondValue, 'bar', customTesters);
},
};
+3 -3
View File
@@ -329,7 +329,7 @@ declare namespace jasmine {
negativeCompare?(actual: any, ...expected: any[]): CustomMatcherResult;
}
type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]) => CustomMatcher;
type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: ReadonlyArray<CustomEqualityTester>) => CustomMatcher;
interface CustomMatcherFactories {
[index: string]: CustomMatcherFactory;
@@ -341,8 +341,8 @@ declare namespace jasmine {
}
interface MatchersUtil {
equals(a: any, b: any, customTesters?: CustomEqualityTester[]): boolean;
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: CustomEqualityTester[]): boolean;
equals(a: any, b: any, customTesters?: ReadonlyArray<CustomEqualityTester>): boolean;
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: ReadonlyArray<CustomEqualityTester>): boolean;
buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string;
}
+3 -3
View File
@@ -917,10 +917,10 @@ describe("jasmine.any", () => {
});
describe('custom asymmetry', function() {
const tester = {
asymmetricMatch: (actual: string) => {
const tester: jasmine.AsymmetricMatcher<string> = {
asymmetricMatch: (actual: string, customTesters) => {
const secondValue = actual.split(',')[1];
return secondValue === 'bar';
return jasmine.matchersUtil.equals(secondValue, 'bar', customTesters);
},
};