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

Function expectStickyStyles

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

Source from the content-addressed store, hash-verified

929 }
930
931 function expectStickyStyles(element: any, zIndex: string, directions: PositionDirections = {}) {
932 expect(element.style.position).toContain('sticky');
933 expect(element.style.zIndex).withContext(`Expected zIndex to be ${zIndex}`).toBe(zIndex);
934
935 ['top', 'bottom', 'left', 'right'].forEach(d => {
936 const directionValue = directions[d];
937
938 if (!directionValue) {
939 // If no expected position for this direction, must either be unset or empty string
940 // If no expected position for this direction, must either be unset or empty string
941 expect(element.style[d] || 'unset')
942 .withContext(`Expected ${d} to be unset`)
943 .toBe('unset');
944 return;
945 }
946
947 const expectationMessage = `Expected direction ${d} to be ${directionValue}`;
948
949 // If the direction contains `px`, we parse the number to be able to avoid deviations
950 // caused by individual browsers.
951 if (directionValue.includes('px')) {
952 expect(Math.round(parseInt(element.style[d])))
953 .withContext(expectationMessage)
954 .toBe(Math.round(parseInt(directionValue)));
955 } else {
956 expect(element.style[d]).withContext(expectationMessage).toBe(directionValue);
957 }
958 });
959 }
960
961 function expectStickyBorderClass(element: any, directions: {[key: string]: boolean} = {}) {
962 ['top', 'bottom', 'left', 'right'].forEach(d => {

Callers 1

table.spec.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected