MCPcopy Create free account
hub / github.com/angular/components / expectStickyStyles

Function expectStickyStyles

src/cdk/table/table.spec.ts:972–1000  ·  view source on GitHub ↗
(element: any, zIndex: string, directions: PositionDirections = {})

Source from the content-addressed store, hash-verified

970 }
971
972 function expectStickyStyles(element: any, zIndex: string, directions: PositionDirections = {}) {
973 expect(element.style.position).toContain('sticky');
974 expect(element.style.zIndex).withContext(`Expected zIndex to be ${zIndex}`).toBe(zIndex);
975
976 ['top', 'bottom', 'left', 'right'].forEach(d => {
977 const directionValue = directions[d];
978
979 if (!directionValue) {
980 // If no expected position for this direction, must either be unset or empty string
981 // If no expected position for this direction, must either be unset or empty string
982 expect(element.style[d] || 'unset')
983 .withContext(`Expected ${d} to be unset`)
984 .toBe('unset');
985 return;
986 }
987
988 const expectationMessage = `Expected direction ${d} to be ${directionValue}`;
989
990 // If the direction contains `px`, we parse the number to be able to avoid deviations
991 // caused by individual browsers.
992 if (directionValue.includes('px')) {
993 expect(Math.round(parseInt(element.style[d])))
994 .withContext(expectationMessage)
995 .toBe(Math.round(parseInt(directionValue)));
996 } else {
997 expect(element.style[d]).withContext(expectationMessage).toBe(directionValue);
998 }
999 });
1000 }
1001
1002 function expectStickyBorderClass(element: any, directions: {[key: string]: boolean} = {}) {
1003 ['top', 'bottom', 'left', 'right'].forEach(d => {

Callers 1

table.spec.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected