From 0bd37dd744e0214ad350df8ff08b492a3f530254 Mon Sep 17 00:00:00 2001 From: seongminn Date: Sat, 21 Mar 2026 17:36:04 +0900 Subject: [PATCH] cover base array sorting in alphabetical and custom order rules --- .../__tests__/recipe.test.ts | 35 +++++++++++ .../custom-order/__tests__/recipe.test.ts | 58 +++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/src/css-rules/alphabetical-order/__tests__/recipe.test.ts b/src/css-rules/alphabetical-order/__tests__/recipe.test.ts index 82ba7ed..971774d 100644 --- a/src/css-rules/alphabetical-order/__tests__/recipe.test.ts +++ b/src/css-rules/alphabetical-order/__tests__/recipe.test.ts @@ -36,6 +36,18 @@ run({ } }); `, + + // Recipe with base as array (ComplexStyleRule) + ` + import { recipe } from '@vanilla-extract/recipes'; + + const myRecipe = recipe({ + base: [{ + alignItems: 'center', + display: 'flex' + }], + }); + `, ], invalid: [ // Recipe with incorrect ordering @@ -88,5 +100,28 @@ run({ }); `, }, + + // Recipe with base array in incorrect order + { + code: ` + import { recipe } from '@vanilla-extract/recipes'; + const myRecipe = recipe({ + base: [{ + display: 'flex', + alignItems: 'center' + }], + }); + `, + errors: [{ messageId: 'alphabeticalOrder' }], + output: ` + import { recipe } from '@vanilla-extract/recipes'; + const myRecipe = recipe({ + base: [{ + alignItems: 'center', + display: 'flex' + }], + }); + `, + }, ], }); diff --git a/src/css-rules/custom-order/__tests__/recipe.test.ts b/src/css-rules/custom-order/__tests__/recipe.test.ts index 16e66e7..871dcdc 100644 --- a/src/css-rules/custom-order/__tests__/recipe.test.ts +++ b/src/css-rules/custom-order/__tests__/recipe.test.ts @@ -88,6 +88,29 @@ run({ }, ], }, + + // Recipe with base as array (ComplexStyleRule) + { + code: ` + import { recipe } from '@vanilla-extract/recipes'; + + const myRecipe = recipe({ + base: [{ + width: '100%', + margin: 0, + display: 'flex', + alignItems: 'center', + backgroundColor: 'white' + }], + }); + `, + options: [ + { + groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'], + sortRemainingProperties: 'concentric', + }, + ], + }, ], invalid: [ // Recipe with incorrect ordering (concentric for remaining) @@ -207,5 +230,40 @@ run({ }); `, }, + + // Recipe with base array in incorrect order + { + code: ` + import { recipe } from '@vanilla-extract/recipes'; + const myRecipe = recipe({ + base: [{ + backgroundColor: 'white', + width: '100%', + display: 'flex', + alignItems: 'center', + margin: 0 + }], + }); + `, + options: [ + { + groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'], + sortRemainingProperties: 'concentric', + }, + ], + errors: [{ messageId: 'incorrectOrder' }], + output: ` + import { recipe } from '@vanilla-extract/recipes'; + const myRecipe = recipe({ + base: [{ + width: '100%', + margin: 0, + display: 'flex', + alignItems: 'center', + backgroundColor: 'white' + }], + }); + `, + }, ], });