@@ -740,6 +740,57 @@ Mix @|milk|milk{200%ml} or @|milk|almond milk{100%ml}
740740 / R e c i p e h a s u n r e s o l v e d a l t e r n a t i v e s .* i n g r e d i e n t G r o u p s .* m i l k / ,
741741 ) ;
742742 } ) ;
743+
744+ it ( "should only require choices expected for the selected variant" , ( ) => {
745+ const shoppingList = new ShoppingList ( ) ;
746+ const recipeWithVariantLinkedChoices = new Recipe ( `
747+ ---
748+ servings: 1
749+ ---
750+ [*] Add @milk{200%ml}|oat milk{200%ml}.
751+
752+ [vegan] Add @water{100%ml}|broth{100%ml}.
753+
754+ [*] Use @|protein|chicken{200%g} or @|protein|turkey{200%g}.
755+
756+ [vegan] Use @|protein|tofu{200%g} or @|protein|tempeh{200%g}.
757+ ` ) ;
758+
759+ expect ( ( ) =>
760+ shoppingList . addRecipe ( recipeWithVariantLinkedChoices , {
761+ choices : {
762+ variant : "vegan" ,
763+ ingredientItems : new Map ( [ [ "ingredient-item-1" , 1 ] ] ) ,
764+ ingredientGroups : new Map ( [ [ "protein" , 1 ] ] ) ,
765+ } ,
766+ } ) ,
767+ ) . not . toThrow ( ) ;
768+ } ) ;
769+
770+ it ( "should only require choices expected for the default variant" , ( ) => {
771+ const shoppingList = new ShoppingList ( ) ;
772+ const recipeWithVariantLinkedChoices = new Recipe ( `
773+ ---
774+ servings: 1
775+ ---
776+ [*] Add @milk{200%ml}|oat milk{200%ml}.
777+
778+ [vegan] Add @water{100%ml}|broth{100%ml}[for vegan].
779+
780+ [*] Use @|protein|chicken{200%g} or @|protein|turkey{200%g}.
781+
782+ [vegan] Use @|protein|tofu{200%g}[for vegan] or @|protein|tempeh{200%g}[for vegan].
783+ ` ) ;
784+
785+ expect ( ( ) =>
786+ shoppingList . addRecipe ( recipeWithVariantLinkedChoices , {
787+ choices : {
788+ ingredientItems : new Map ( [ [ "ingredient-item-0" , 1 ] ] ) ,
789+ ingredientGroups : new Map ( [ [ "protein" , 1 ] ] ) ,
790+ } ,
791+ } ) ,
792+ ) . not . toThrow ( ) ;
793+ } ) ;
743794 } ) ;
744795
745796 describe ( "Association with CategoryConfig" , ( ) => {
0 commit comments