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

Function createMockCSSRegisteredProperty

tests/mocks.ts:914–966  ·  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

912}
913
914export function createMockCSSRegisteredProperty(
915 name: string,
916 options: {
917 syntax?: string;
918 inherits?: boolean;
919 initialValue?: string;
920 sourceURL?: string;
921 range?: {
922 startLine: number;
923 startColumn: number;
924 endLine: number;
925 endColumn: number;
926 };
927 isProgrammatic?: boolean;
928 } = {},
929): MockCSSRegisteredProperty {
930 const properties = [
931 createMockCSSProperty('syntax', options.syntax ?? '"*"'),
932 createMockCSSProperty('inherits', String(options.inherits ?? false)),
933 ];
934 if (options.initialValue) {
935 properties.push(
936 createMockCSSProperty('initial-value', options.initialValue),
937 );
938 }
939
940 let parentRule: sinon.SinonStubbedInstance<DevTools.CSSRule.CSSPropertyRule> | null =
941 null;
942 if (!options.isProgrammatic) {
943 const mockRule = sinon.createStubInstance(DevTools.CSSRule.CSSPropertyRule);
944 attachRuleMeta(mockRule, options.sourceURL);
945 mockRule.propertyName.returns(createCSSValue(name));
946 parentRule = mockRule;
947 }
948
949 const style = createMockCSSStyleDeclaration(properties, {
950 rule: parentRule,
951 range: options.range,
952 });
953 if (parentRule) {
954 Object.assign(parentRule, {style});
955 }
956
957 const prop = sinon.createStubInstance(
958 DevTools.CSSMatchedStyles.CSSRegisteredProperty,
959 );
960 prop.propertyName.returns(name);
961 prop.inherits.returns(options.inherits ?? false);
962 prop.syntax.returns(options.syntax ?? '"*"');
963 prop.initialValue.returns(options.initialValue ?? null);
964 prop.style.returns(style);
965 return prop;
966}
967
968export function createMockCSSFunctionRule(
969 nameWithParams: string,

Callers 1

Calls 4

createMockCSSPropertyFunction · 0.85
attachRuleMetaFunction · 0.85
createCSSValueFunction · 0.85

Tested by

no test coverage detected