MCPcopy Index your code
hub / github.com/angular/components / testSingleColumnSortDirectionSequence

Function testSingleColumnSortDirectionSequence

src/material/sort/sort.spec.ts:409–439  ·  view source on GitHub ↗

* Performs a sequence of sorting on a single column to see if the sort directions are * consistent with expectations. Detects any changes in the fixture to reflect any changes in * the inputs and resets the MatSort to remove any side effects from previous tests.

(
  fixture: ComponentFixture<SimpleMatSortApp | MatSortWithoutExplicitInputs>,
  expectedSequence: SortDirection[],
  id: SimpleMatSortAppColumnIds = 'defaultA',
)

Source from the content-addressed store, hash-verified

407 * the inputs and resets the MatSort to remove any side effects from previous tests.
408 */
409function testSingleColumnSortDirectionSequence(
410 fixture: ComponentFixture<SimpleMatSortApp | MatSortWithoutExplicitInputs>,
411 expectedSequence: SortDirection[],
412 id: SimpleMatSortAppColumnIds = 'defaultA',
413) {
414 // Detect any changes that were made in preparation for this sort sequence
415 fixture.detectChanges();
416
417 // Reset the sort to make sure there are no side affects from previous tests
418 const component = fixture.componentInstance;
419 component.matSort.active = '';
420 component.matSort.direction = '';
421
422 // Run through the sequence to confirm the order
423 const actualSequence = expectedSequence.map(() => {
424 component.sort(id);
425
426 // Check that the sort event's active sort is consistent with the MatSort
427 expect(component.matSort.active).toBe(id);
428 expect(component.latestSortEvent.active).toBe(id);
429
430 // Check that the sort event's direction is consistent with the MatSort
431 expect(component.matSort.direction).toBe(component.latestSortEvent.direction);
432 return component.matSort.direction;
433 });
434 expect(actualSequence).toEqual(expectedSequence);
435
436 // Expect that performing one more sort will loop it back to the beginning.
437 component.sort(id);
438 expect(component.matSort.direction).toBe(expectedSequence[0]);
439}
440
441/** Column IDs of the SimpleMatSortApp for typing of function params in the component (e.g. sort) */
442type SimpleMatSortAppColumnIds = 'defaultA' | 'defaultB' | 'overrideStart' | 'overrideDisableClear';

Callers 1

sort.spec.tsFile · 0.85

Calls 1

sortMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…