# test.govlab/quality/core/predicates/css.predicate.test.ts

> 19 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-quality-core-predicates-css-predicate-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/quality/core/predicates/css.predicate.test.ts.txt

Listed in [test.govlab/quality/core/predicates](https://banes-lab.com/api/source/testing/test.govlab/quality/core/predicates.md), after [test.govlab/quality/core/predicates/coverage.predicate.test.ts](https://banes-lab.com/source/testing/test.govlab/quality/core/predicates/coverage.predicate.test.ts.md) and before [test.govlab/quality/core/predicates/eslint.predicate.test.ts](https://banes-lab.com/source/testing/test.govlab/quality/core/predicates/eslint.predicate.test.ts.md).

## Contained in

- [test.govlab/quality/core/predicates](https://banes-lab.com/anatomy/testing/folder-testing-test-govlab-quality-core-predicates.md)

## Source

```typescript
import { customPropertyStartsWith, hasPxUnit, insideAtRule } from "@govlab/quality/core/predicates/css.predicate.ts";
import { expect, test } from "vitest";

test("hasPxUnit reports a px token anywhere in the value", () => {
    expect(hasPxUnit("1rem 2px")).toBe(true);
    expect(hasPxUnit("1rem 50%")).toBe(false);
});

test("customPropertyStartsWith matches the prefix unless an exclusion occurs in the name", () => {
    expect(customPropertyStartsWith("--border-width", "--border-")).toBe(true);
    expect(customPropertyStartsWith("--border-neutral", "--border-", ["neutral"])).toBe(false);
    expect(customPropertyStartsWith("--space-sm", "--border-")).toBe(false);
});

test("insideAtRule walks the ancestors for a named at-rule", () => {
    const media = { name: "media", type: "atrule" };
    const rule = { parent: media, type: "rule" };
    const decl = { parent: rule, type: "decl" };
    expect(insideAtRule(decl, new Set(["media"]))).toBe(true);
    expect(insideAtRule(decl, new Set(["container"]))).toBe(false);
    expect(insideAtRule(undefined, new Set(["media"]))).toBe(false);
});
```
