MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / createMockCSSRegisteredProperty

Function createMockCSSRegisteredProperty

tests/mocks.ts:955–1007  ·  view source on GitHub ↗
(
  name: string,
  options: {
    syntax?: string;
    inherits?: boolean;
    initialValue?: string;
    sourceURL?: string;
    range?: {
      startLine: number;
      startColumn: number;
      endLine: number;
      endColumn: number;
    };
    isProgrammatic?: boolean;
  } = {},
)

Source from the content-addressed store, hash-verified

953}
954
955export function createMockCSSRegisteredProperty(
956 name: string,
957 options: {
958 syntax?: string;
959 inherits?: boolean;
960 initialValue?: string;
961 sourceURL?: string;
962 range?: {
963 startLine: number;
964 startColumn: number;
965 endLine: number;
966 endColumn: number;
967 };
968 isProgrammatic?: boolean;
969 } = {},
970): MockCSSRegisteredProperty {
971 const properties = [
972 createMockCSSProperty('syntax', options.syntax ?? '"*"'),
973 createMockCSSProperty('inherits', String(options.inherits ?? false)),
974 ];
975 if (options.initialValue) {
976 properties.push(
977 createMockCSSProperty('initial-value', options.initialValue),
978 );
979 }
980
981 let parentRule: sinon.SinonStubbedInstance<DevTools.CSSRule.CSSPropertyRule> | null =
982 null;
983 if (!options.isProgrammatic) {
984 const mockRule = sinon.createStubInstance(DevTools.CSSRule.CSSPropertyRule);
985 attachRuleMeta(mockRule, options.sourceURL);
986 mockRule.propertyName.returns(createCSSValue(name));
987 parentRule = mockRule;
988 }
989
990 const style = createMockCSSStyleDeclaration(properties, {
991 rule: parentRule,
992 range: options.range,
993 });
994 if (parentRule) {
995 Object.assign(parentRule, {style});
996 }
997
998 const prop = sinon.createStubInstance(
999 DevTools.CSSMatchedStyles.CSSRegisteredProperty,
1000 );
1001 prop.propertyName.returns(name);
1002 prop.inherits.returns(options.inherits ?? false);
1003 prop.syntax.returns(options.syntax ?? '"*"');
1004 prop.initialValue.returns(options.initialValue ?? null);
1005 prop.style.returns(style);
1006 return prop;
1007}
1008
1009export function createMockCSSFunctionRule(
1010 nameWithParams: string,

Callers 1

Calls 4

createMockCSSPropertyFunction · 0.85
attachRuleMetaFunction · 0.85
createCSSValueFunction · 0.85

Tested by

no test coverage detected