@@ -217,8 +217,48 @@ describe('bin-pack with maxWidth option', function() {
217217 assert . equal ( result . items . length , bins . length , "Result has same amount of items as the source" ) ;
218218 verifyResult ( result , result . items ) ;
219219 } )
220+ } )
221+
222+ describe ( 'with strictMax: true' , function ( ) {
223+ it ( 'packs items that exceed the maximum width at the left edge' , function ( ) {
224+ var bins = [
225+ { width : 100 , height : 10 } ,
226+ { width : 110 , height : 10 } ,
227+ ] ;
228+
229+ var result = pack ( bins , { maxWidth : 90 , strictMax : true } ) ;
230+ assert . ok ( 'items' in result , "Result has items" ) ;
231+ assert . equal ( result . items . length , bins . length , "Result has same amount of items as the source" ) ;
232+ assert . ok ( result . width === 110 , 'Width is that of the widest item' )
233+ verifyResult ( result , result . items ) ;
234+ } )
220235
221- describe ( 'with strictMax: true' , function ( ) {
222- it ( 'rejects bins that exceed the maximum' )
236+ it ( 'does not unnecessarily pack items to exceed the maximum width' , function ( ) {
237+ var bins = [
238+ { width : 10 , height : 110 } ,
239+ { width : 10 , height : 110 } ,
240+ { width : 10 , height : 110 } ,
241+ { width : 40 , height : 48 } ,
242+ { width : 40 , height : 48 } ,
243+ { width : 40 , height : 48 } ,
244+ { width : 50 , height : 48 } ,
245+ { width : 50 , height : 48 } ,
246+ { width : 50 , height : 48 } ,
247+ { width : 60 , height : 48 } ,
248+ { width : 60 , height : 48 } ,
249+ { width : 70 , height : 48 } ,
250+ { width : 70 , height : 48 } ,
251+ { width : 30 , height : 48 } ,
252+ { width : 30 , height : 48 } ,
253+ { width : 30 , height : 48 } ,
254+ ] ;
255+
256+ var result = pack ( bins , { maxWidth : 60 , strictMax : true } ) ;
257+ assert . ok ( 'items' in result , "Result has items" ) ;
258+ assert . equal ( result . items . length , bins . length , "Result has same amount of items as the source" ) ;
259+ assert . ok ( result . width === 70 , 'Width is that of the widest item' )
260+ verifyResult ( result , result . items ) ;
223261 } )
262+
263+ it ( 'rejects bins that exceed the maximum' )
224264} )
0 commit comments