mirror of
https://github.com/antebudimir/eslint-plugin-vanilla-extract.git
synced 2025-12-31 08:53:33 +00:00
Add comprehensive tests for shared utility modules to improve code coverage: - Test property name extraction edge cases - Test CSS property priority map with invalid groups - Test order strategy visitor creator edge cases - Test font face property order enforcer early returns - Test style node processor with arrays and null values These tests ensure all code paths in shared utilities are properly exercised, including error handling and edge cases.
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import tsParser from '@typescript-eslint/parser';
|
|
import { run } from 'eslint-vitest-rule-tester';
|
|
import testRuleForPropertyNameExtractor from './test-property-name-rule.js';
|
|
|
|
run({
|
|
name: 'vanilla-extract/property-name-extractor-tests',
|
|
rule: testRuleForPropertyNameExtractor,
|
|
languageOptions: {
|
|
parser: tsParser,
|
|
parserOptions: {
|
|
ecmaVersion: 2022,
|
|
sourceType: 'module',
|
|
},
|
|
},
|
|
valid: [
|
|
// Test for identifier and string literal keys (should return names)
|
|
`
|
|
import { style } from '@vanilla-extract/css';
|
|
|
|
const myStyle = style({
|
|
color: 'blue',
|
|
'background-color': 'white',
|
|
fontSize: '16px'
|
|
});
|
|
`,
|
|
|
|
// Test for computed property with non-string literal (should return empty string)
|
|
`
|
|
import { style } from '@vanilla-extract/css';
|
|
|
|
const myStyle = style({
|
|
[42]: 'numeric key',
|
|
[true]: 'boolean key'
|
|
});
|
|
`,
|
|
|
|
// Test for computed property with complex expression
|
|
`
|
|
import { style } from '@vanilla-extract/css';
|
|
|
|
const myStyle = style({
|
|
[Math.random() > 0.5 ? 'dynamicKey' : 'otherKey']: 'dynamic value'
|
|
});
|
|
`,
|
|
|
|
// Test for property with template literal key
|
|
`
|
|
import { style } from '@vanilla-extract/css';
|
|
|
|
const prefix = 'webkit';
|
|
const myStyle = style({
|
|
[\`-\${prefix}-appearance\`]: 'none'
|
|
});
|
|
`,
|
|
],
|
|
invalid: [],
|
|
});
|