Skip to content

Commit 3bd81a3

Browse files
committed
new goldens
1 parent c5fe890 commit 3bd81a3

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed

src/cdk/table/text-column.spec.ts

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import {Component} from '@angular/core';
22
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
3+
4+
import {getTableTextColumnMissingParentTableError} from './table-errors';
35
import {CdkTableModule} from './table-module';
46
import {expectTableToMatchContent} from './table.spec';
5-
import {TextColumnOptions, TEXT_COLUMN_OPTIONS} from './text-column';
6-
import {getTableTextColumnMissingParentTableError} from './table-errors';
7+
import {TEXT_COLUMN_OPTIONS, TextColumnOptions} from './text-column';
8+
79

810
describe('CdkTextColumn', () => {
911
let fixture: ComponentFixture<BasicTextColumnApp>;
1012
let component: BasicTextColumnApp;
1113
let tableElement: HTMLElement;
1214

1315
beforeEach(async(() => {
14-
TestBed.configureTestingModule({
15-
imports: [CdkTableModule],
16-
declarations: [
17-
BasicTextColumnApp,
18-
MissingTableApp,
19-
],
20-
}).compileComponents();
16+
TestBed
17+
.configureTestingModule({
18+
imports: [CdkTableModule],
19+
declarations: [
20+
BasicTextColumnApp,
21+
MissingTableApp,
22+
],
23+
})
24+
.compileComponents();
2125
}));
2226

2327
beforeEach(() => {
@@ -38,8 +42,7 @@ describe('CdkTextColumn', () => {
3842

3943
it('should throw an error if the text column is not in the content of a table', () => {
4044
expect(() => TestBed.createComponent(MissingTableApp).detectChanges())
41-
.toThrowError(getTableTextColumnMissingParentTableError().message);
42-
45+
.toThrowError(getTableTextColumnMissingParentTableError().message);
4346
});
4447

4548
it('should allow for alternate header text', () => {
@@ -89,21 +92,6 @@ describe('CdkTextColumn', () => {
8992
]);
9093
});
9194

92-
it('should be able to justify the text', () => {
93-
component.justifyC = 'end';
94-
fixture.detectChanges();
95-
96-
const headerB = tableElement.querySelector('th:nth-child(2')! as HTMLElement;
97-
const headerC = tableElement.querySelector('th:nth-child(3')! as HTMLElement;
98-
expect(headerB.style.textAlign).toBe('start');
99-
expect(headerC.style.textAlign).toBe('end');
100-
101-
const cellB = tableElement.querySelector('td:nth-child(2')! as HTMLElement;
102-
const cellC = tableElement.querySelector('td:nth-child(3')! as HTMLElement;
103-
expect(cellB.style.textAlign).toBe('start');
104-
expect(cellC.style.textAlign).toBe('end');
105-
});
106-
10795
describe('with options', () => {
10896
function createTestComponent(options: TextColumnOptions<any>) {
10997
// Reset the previously configured testing module to be able set new providers.

tools/public_api_guard/cdk/table.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,21 @@ export declare class CdkTable<T> implements AfterContentChecked, CollectionViewe
179179
export declare class CdkTableModule {
180180
}
181181

182+
export declare class CdkTextColumn<T> implements OnDestroy, OnInit {
183+
_name: string;
184+
cell: CdkCellDef;
185+
columnDef: CdkColumnDef;
186+
dataAccessor: (data: T, name: string) => string;
187+
headerCell: CdkHeaderCellDef;
188+
headerText: string;
189+
justify: 'start' | 'end';
190+
name: string;
191+
constructor(table: CdkTable<T>, options: TextColumnOptions<T>);
192+
_createDefaultHeaderText(): string;
193+
ngOnDestroy(): void;
194+
ngOnInit(): void;
195+
}
196+
182197
export interface CellDef {
183198
template: TemplateRef<any>;
184199
}
@@ -236,3 +251,10 @@ export declare class StickyStyler {
236251
updateStickyColumns(rows: HTMLElement[], stickyStartStates: boolean[], stickyEndStates: boolean[]): void;
237252
updateStickyFooterContainer(tableElement: Element, stickyStates: boolean[]): void;
238253
}
254+
255+
export declare const TEXT_COLUMN_OPTIONS: InjectionToken<TextColumnOptions<any>>;
256+
257+
export interface TextColumnOptions<T> {
258+
defaultDataAccessor?: (data: T, name: string) => string;
259+
defaultHeaderTextTransform?: (name: string) => string;
260+
}

tools/public_api_guard/lib/table.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,6 @@ export declare class MatTableDataSource<T> extends DataSource<T> {
6969

7070
export declare class MatTableModule {
7171
}
72+
73+
export declare class MatTextColumn<T> extends CdkTextColumn<T> {
74+
}

0 commit comments

Comments
 (0)