Skip to content

Commit 2f7756e

Browse files
committed
remove custom matcher
1 parent 98b703c commit 2f7756e

File tree

4 files changed

+21
-34
lines changed

4 files changed

+21
-34
lines changed

src/lib/core/testing/jasmine-matchers.ts

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,21 @@
1010
* Collection of useful custom jasmine matchers for tests.
1111
*/
1212
export const customMatchers: jasmine.CustomMatcherFactories = {
13-
/** Matcher verifying that the element has the expected role attribute. */
1413
toBeRole: () => {
1514
return {
1615
compare: function (element: Element, expectedRole: string) {
17-
return checkElementAttribute(element, 'role', expectedRole);
18-
}
19-
};
20-
},
16+
const result: jasmine.CustomMatcherResult = {pass: false};
17+
const actualRole = element.getAttribute('role');
2118

22-
/** Matcher verifying that the element has the expected aria label. */
23-
toHaveAriaLabel: () => {
24-
return {
25-
compare: function (element: Element, expectedAriaLabel: string) {
26-
return checkElementAttribute(element, 'aria-label', expectedAriaLabel);
27-
}
28-
};
29-
},
30-
};
19+
result.pass = actualRole === expectedRole;
20+
result.message = `Expected role for ${element.tagName} to be ${expectedRole}`;
3121

32-
function checkElementAttribute(element, attr, expectation): jasmine.CustomMatcherResult {
33-
const result: jasmine.CustomMatcherResult = {pass: false};
34-
const actual = element.getAttribute(attr);
22+
if (!result.pass) {
23+
result.message += ` but was ${actualRole}`;
24+
}
3525

36-
result.pass = actual === expectation;
37-
result.message = `Expected aria-label for ${element.tagName} to be ${expectation}`;
38-
39-
if (!result.pass) {
40-
result.message += ` but was ${actual}`;
26+
return result;
27+
}
28+
};
4129
}
42-
43-
return result;
44-
}
30+
};

src/lib/paginator/paginator.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {customMatchers} from '../core/testing/jasmine-matchers';
1212
import {dispatchMouseEvent} from '../core/testing/dispatch-events';
1313

1414

15-
describe('MdPaginator', () => {
15+
fdescribe('MdPaginator', () => {
1616
let fixture: ComponentFixture<MdPaginatorApp>;
1717
let component: MdPaginatorApp;
1818
let paginator: MdPaginator;
@@ -93,12 +93,14 @@ describe('MdPaginator', () => {
9393
});
9494

9595
it('should show right aria-labels for select and buttons', () => {
96-
expect(fixture.nativeElement.querySelector('.mat-select'))
97-
.toHaveAriaLabel('Items per page:');
98-
expect(fixture.nativeElement.querySelector('.mat-paginator-navigation-previous'))
99-
.toHaveAriaLabel('Previous page');
100-
expect(fixture.nativeElement.querySelector('.mat-paginator-navigation-next'))
101-
.toHaveAriaLabel('Next page');
96+
const select = fixture.nativeElement.querySelector('.mat-select');
97+
expect(select.getAttribute('aria-label')).toBe('Items per page:');
98+
99+
const prevButton = fixture.nativeElement.querySelector('.mat-paginator-navigation-previous');
100+
expect(prevButton.getAttribute('aria-label')).toBe('Previous page');
101+
102+
const nextButton = fixture.nativeElement.querySelector('.mat-paginator-navigation-next');
103+
expect(nextButton.getAttribute('aria-label')).toBe('Next page');
102104
});
103105
});
104106

src/lib/typings.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ declare var module: {id: string};
44
declare namespace jasmine {
55
interface Matchers {
66
toBeRole(expectedRole: string): boolean;
7-
toHaveAriaLabel(expectedAriaLabel: string): boolean;
8-
toHaveAttribute(attr: string, test: string, expectedContent: any[]): boolean;
97
toMatchTableContent(expectedContent: any[]): boolean;
108
}
119
}

tools/dgeni/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps)
9797
'input/index.ts',
9898
'list/index.ts',
9999
'menu/index.ts',
100+
'paginator/index.ts',
100101
'progress-bar/index.ts',
101102
'progress-spinner/index.ts',
102103
'radio/index.ts',

0 commit comments

Comments
 (0)