fix(testing): remove the `toMatchPattern` matcher (jasmine has `toMatch`)

BREAKING CHANGE:

Before:

    expect(...).toMatchPattern(pattern);

After:

    expect(...).toMatch(pattern);
This commit is contained in:
Victor Berchet 2016-06-22 14:53:02 -07:00
parent 5face35ae5
commit 6420f75320
6 changed files with 16 additions and 43 deletions

View File

@ -44,10 +44,10 @@ export function main() {
} }
expect(capturedErrorMessage) expect(capturedErrorMessage)
.toMatchPattern(/Unable to apply styles due to missing a state: "missing_state"/g); .toMatch(/Unable to apply styles due to missing a state: "missing_state"/g);
expect(capturedErrorMessage) expect(capturedErrorMessage)
.toMatchPattern(/Animation states via styles must be prefixed with a ":"/); .toMatch(/Animation states via styles must be prefixed with a ":"/);
}); });
}); });
} }

View File

@ -221,8 +221,8 @@ export function main() {
expect(step.keyframes.length).toEqual(4); expect(step.keyframes.length).toEqual(4);
expect(step.keyframes[0].offset).toEqual(0); expect(step.keyframes[0].offset).toEqual(0);
expect(step.keyframes[1].offset).toMatchPattern(/^0\.33/); expect(step.keyframes[1].offset).toMatch(/^0\.33/);
expect(step.keyframes[2].offset).toMatchPattern(/^0\.66/); expect(step.keyframes[2].offset).toMatch(/^0\.66/);
expect(step.keyframes[3].offset).toEqual(1); expect(step.keyframes[3].offset).toEqual(1);
}); });
@ -275,7 +275,7 @@ export function main() {
expect(errors.length).toEqual(1); expect(errors.length).toEqual(1);
var error = errors[0]; var error = errors[0];
expect(error.msg).toMatchPattern(/Not all style\(\) entries contain an offset/); expect(error.msg).toMatch(/Not all style\(\) entries contain an offset/);
}); });
it('should use an existing style used earlier in the animation sequence if not defined in the first keyframe', it('should use an existing style used earlier in the animation sequence if not defined in the first keyframe',

View File

@ -274,8 +274,7 @@ export function main() {
capturedMessage = e.rawMessage; capturedMessage = e.rawMessage;
} }
expect(capturedMessage) expect(capturedMessage).toMatch(/Unexpected character \[\>\] at column 0:7 in expression/g);
.toMatchPattern(/Unexpected character \[\>\] at column 0:7 in expression/g);
capturedMessage = null; capturedMessage = null;
try { try {

View File

@ -417,11 +417,11 @@ export function main() {
expect(errors.length).toEqual(3); expect(errors.length).toEqual(3);
expect(errors[0].msg).toMatchPattern(/Unexpected character \[\[\] at column 0:7/g); expect(errors[0].msg).toMatch(/Unexpected character \[\[\] at column 0:7/g);
expect(errors[1].msg).toMatchPattern(/Unexpected character \[%\] at column 0:12/g); expect(errors[1].msg).toMatch(/Unexpected character \[%\] at column 0:12/g);
expect(errors[2].msg).toMatchPattern(/Unexpected character \[}\] at column 0:19/g); expect(errors[2].msg).toMatch(/Unexpected character \[}\] at column 0:19/g);
}); });
it('should throw an error if an attribute selector is not closed properly', () => { it('should throw an error if an attribute selector is not closed properly', () => {
@ -429,7 +429,7 @@ export function main() {
var output = parse(styles); var output = parse(styles);
var errors = output.errors; var errors = output.errors;
expect(errors[0].msg).toMatchPattern(/Unbalanced CSS attribute selector at column 0:12/g); expect(errors[0].msg).toMatch(/Unbalanced CSS attribute selector at column 0:12/g);
}); });
it('should throw an error if a pseudo function selector is not closed properly', () => { it('should throw an error if a pseudo function selector is not closed properly', () => {
@ -438,8 +438,7 @@ export function main() {
var errors = output.errors; var errors = output.errors;
expect(errors[0].msg) expect(errors[0].msg)
.toMatchPattern( .toMatch(/Character does not match expected Character value \("{" should match "\)"\)/);
/Character does not match expected Character value \("{" should match "\)"\)/);
}); });
it('should raise an error when a semi colon is missing from a CSS style/pair that isn\'t the last entry', it('should raise an error when a semi colon is missing from a CSS style/pair that isn\'t the last entry',
@ -455,8 +454,7 @@ export function main() {
expect(errors.length).toEqual(1); expect(errors.length).toEqual(1);
expect(errors[0].msg) expect(errors[0].msg)
.toMatchPattern( .toMatch(/The CSS key\/value definition did not end with a semicolon at column 1:15/g);
/The CSS key\/value definition did not end with a semicolon at column 1:15/g);
}); });
it('should parse the inner value of a :not() pseudo-selector as a CSS selector', () => { it('should parse the inner value of a :not() pseudo-selector as a CSS selector', () => {
@ -520,18 +518,17 @@ export function main() {
expect(errors.length).toEqual(4); expect(errors.length).toEqual(4);
expect(errors[0].msg) expect(errors[0].msg)
.toMatchPattern( .toMatch(
/Identifier does not match expected Character value \("color" should match ":"\) at column 1:19/g); /Identifier does not match expected Character value \("color" should match ":"\) at column 1:19/g);
expect(errors[1].msg) expect(errors[1].msg)
.toMatchPattern( .toMatch(/The CSS key\/value definition did not end with a semicolon at column 2:15/g);
/The CSS key\/value definition did not end with a semicolon at column 2:15/g);
expect(errors[2].msg) expect(errors[2].msg)
.toMatchPattern(/The CSS property was not paired with a style value at column 3:8/g); .toMatch(/The CSS property was not paired with a style value at column 3:8/g);
expect(errors[3].msg) expect(errors[3].msg)
.toMatchPattern(/The CSS property was not paired with a style value at column 4:8/g); .toMatch(/The CSS property was not paired with a style value at column 4:8/g);
}); });
it('should recover from CSS key/value parse errors', () => { it('should recover from CSS key/value parse errors', () => {

View File

@ -27,14 +27,6 @@ export function main() {
}); });
}); });
describe('toMatchPAttern', () => {
it('should assert that a string matches a given pattern', () => {
expect('matias').toMatchPattern(/ias$/g);
expect('tobias').toMatchPattern(/ias$/g);
expect('joonas').not.toMatchPattern(/ias$/g);
});
});
describe('toEqual for Maps', () => { describe('toEqual for Maps', () => {
it('should detect equality for same reference', () => { it('should detect equality for same reference', () => {
var m1 = MapWrapper.createFromStringMap({'a': 1}); var m1 = MapWrapper.createFromStringMap({'a': 1});

View File

@ -253,21 +253,6 @@ _global.beforeEach(function() {
}; };
}, },
toMatchPattern() {
return {compare: buildError(false), negativeCompare: buildError(true)};
function buildError(isNot: any /** TODO #???? */) {
return function(actual: any /** TODO #???? */, regex: any /** TODO #???? */) {
return {
pass: regex.test(actual) == !isNot,
get message() {
return `Expected ${actual} ${isNot ? 'not ' : ''}to match ${regex.toString()}`;
}
};
};
}
},
toImplement: function() { toImplement: function() {
return { return {
compare: function( compare: function(