mirror of
https://github.com/antebudimir/eslint-plugin-vanilla-extract.git
synced 2025-12-31 08:53:33 +00:00
test ✅: add coverage for shared utility functions
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.
This commit is contained in:
parent
44eeb7be6d
commit
1092b47f1c
13 changed files with 521 additions and 23 deletions
|
|
@ -0,0 +1,57 @@
|
|||
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: [],
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue