@@ -17,8 +17,10 @@ describe('ComparisonGrid', () => {
1717 columns : cols ( 'lodash@4.17.21' , 'underscore@1.13.6' ) ,
1818 } ,
1919 } )
20- expect ( component . text ( ) ) . toContain ( 'lodash@4.17.21' )
21- expect ( component . text ( ) ) . toContain ( 'underscore@1.13.6' )
20+ expect ( component . text ( ) ) . toContain ( 'lodash' )
21+ expect ( component . text ( ) ) . toContain ( '@4.17.21' )
22+ expect ( component . text ( ) ) . toContain ( 'underscore' )
23+ expect ( component . text ( ) ) . toContain ( '@1.13.6' )
2224 } )
2325
2426 it ( 'renders correct number of header cells' , async ( ) => {
@@ -43,74 +45,61 @@ describe('ComparisonGrid', () => {
4345 expect ( component . find ( '.comparison-cell-nodep' ) . exists ( ) ) . toBe ( true )
4446 } )
4547
46- it ( 'truncates long header text with title attribute' , async ( ) => {
48+ it ( 'renders package name and version on separate clamped lines with a full title attribute' , async ( ) => {
4749 const longName = 'very-long-package-name@1.0.0-beta.1'
4850 const component = await mountSuspended ( ComparisonGrid , {
4951 props : {
5052 columns : cols ( longName , 'short' ) ,
5153 } ,
5254 } )
53- const links = component . findAll ( 'a.truncate' )
54- const longLink = links . find ( a => a . text ( ) === longName )
55- expect ( longLink ?. attributes ( 'title' ) ) . toBe ( longName )
55+
56+ const link = component . find ( `a[title="${ longName } "]` )
57+ expect ( link . exists ( ) ) . toBe ( true )
58+ expect ( link . attributes ( 'title' ) ) . toBe ( longName )
59+ expect ( link . findAll ( '.line-clamp-1' ) ) . toHaveLength ( 2 )
5660 } )
5761 } )
5862
5963 describe ( 'column layout' , ( ) => {
60- it ( 'applies columns-2 class for 2 columns' , async ( ) => {
64+ it ( 'sets --package-count to the number of package columns' , async ( ) => {
6165 const component = await mountSuspended ( ComparisonGrid , {
6266 props : {
6367 columns : cols ( 'a' , 'b' ) ,
6468 } ,
6569 } )
66- expect ( component . find ( '.columns-2' ) . exists ( ) ) . toBe ( true )
70+ const grid = component . find ( '.comparison-grid' )
71+ expect ( grid . attributes ( 'style' ) ) . toContain ( '--package-count: 2' )
6772 } )
6873
69- it ( 'applies columns-3 class for 2 packages + no-dep ' , async ( ) => {
74+ it ( 'includes the no-dependency column in --package-count ' , async ( ) => {
7075 const component = await mountSuspended ( ComparisonGrid , {
7176 props : {
7277 columns : cols ( 'a' , 'b' ) ,
7378 showNoDependency : true ,
7479 } ,
7580 } )
76- expect ( component . find ( '.columns-3' ) . exists ( ) ) . toBe ( true )
77- } )
78-
79- it ( 'applies columns-4 class for 4 columns' , async ( ) => {
80- const component = await mountSuspended ( ComparisonGrid , {
81- props : {
82- columns : cols ( 'a' , 'b' , 'c' , 'd' ) ,
83- } ,
84- } )
85- expect ( component . find ( '.columns-4' ) . exists ( ) ) . toBe ( true )
81+ const grid = component . find ( '.comparison-grid' )
82+ expect ( grid . attributes ( 'style' ) ) . toContain ( '--package-count: 3' )
8683 } )
8784
88- it ( 'sets min-width for 4 columns to 800px ' , async ( ) => {
85+ it ( 'supports four package columns with the generic grid layout ' , async ( ) => {
8986 const component = await mountSuspended ( ComparisonGrid , {
9087 props : {
9188 columns : cols ( 'a' , 'b' , 'c' , 'd' ) ,
9289 } ,
9390 } )
94- expect ( component . find ( '.min-w-\\[800px\\]' ) . exists ( ) ) . toBe ( true )
95- } )
96-
97- it ( 'sets min-width for 2-3 columns to 600px' , async ( ) => {
98- const component = await mountSuspended ( ComparisonGrid , {
99- props : {
100- columns : cols ( 'a' , 'b' ) ,
101- } ,
102- } )
103- expect ( component . find ( '.min-w-\\[600px\\]' ) . exists ( ) ) . toBe ( true )
91+ const grid = component . find ( '.comparison-grid' )
92+ expect ( grid . attributes ( 'style' ) ) . toContain ( '--package-count: 4' )
10493 } )
10594
106- it ( 'sets --columns CSS variable' , async ( ) => {
95+ it ( 'sets --package-count CSS variable' , async ( ) => {
10796 const component = await mountSuspended ( ComparisonGrid , {
10897 props : {
10998 columns : cols ( 'a' , 'b' , 'c' ) ,
11099 } ,
111100 } )
112101 const grid = component . find ( '.comparison-grid' )
113- expect ( grid . attributes ( 'style' ) ) . toContain ( '--columns : 3' )
102+ expect ( grid . attributes ( 'style' ) ) . toContain ( '--package-count : 3' )
114103 } )
115104 } )
116105
0 commit comments