@@ -301,4 +301,70 @@ describe('CodeListing', () => {
301301
302302 expect ( wrapper . classes ( ) ) . toContain ( 'single-line' ) ;
303303 } ) ;
304+
305+ it ( 'does not wrap when wrap=0' , async ( ) => {
306+ const wrapper = shallowMount ( CodeListing , {
307+ propsData : {
308+ syntax : 'swift' ,
309+ content : [ 'let foo = "bar"' ] ,
310+ wrap : 0 ,
311+ } ,
312+ } ) ;
313+ await flushPromises ( ) ;
314+
315+ expect ( wrapper . classes ( ) ) . not . toContain ( 'is-wrapped' ) ;
316+
317+ const style = wrapper . attributes ( 'style' ) || '' ;
318+ expect ( style ) . not . toMatch ( / - - w r a p - c h : \s * \d + / ) ;
319+ } ) ;
320+
321+ it ( 'wraps when wrap>0 and exposes the width in style' , async ( ) => {
322+ const wrapper = shallowMount ( CodeListing , {
323+ propsData : {
324+ syntax : 'swift' ,
325+ content : [ 'let foo = "bar"' ] ,
326+ wrap : 80 ,
327+ } ,
328+ } ) ;
329+ await flushPromises ( ) ;
330+
331+ expect ( wrapper . classes ( ) ) . toContain ( 'is-wrapped' ) ;
332+
333+ const style = wrapper . attributes ( 'style' ) || '' ;
334+ expect ( style ) . toMatch ( / - - w r a p - c h : \s * 8 0 \b / ) ;
335+ } ) ;
336+
337+ it ( 'reacts when wrap changes' , async ( ) => {
338+ const wrapper = shallowMount ( CodeListing , {
339+ propsData : {
340+ syntax : 'swift' ,
341+ content : [ 'let foo = "bar"' ] ,
342+ wrap : 80 ,
343+ } ,
344+ } ) ;
345+ await flushPromises ( ) ;
346+
347+ expect ( wrapper . classes ( ) ) . toContain ( 'is-wrapped' ) ;
348+
349+ let style = wrapper . attributes ( 'style' ) || '' ;
350+ expect ( style ) . toMatch ( / - - w r a p - c h : \s * 8 0 \b / ) ;
351+
352+ await wrapper . setProps ( { wrap : 0 } ) ;
353+ style = wrapper . attributes ( 'style' ) || '' ;
354+ expect ( wrapper . classes ( ) ) . not . toContain ( 'is-wrapped' ) ;
355+ expect ( style ) . not . toMatch ( / - - w r a p - c h : \s * \d + / ) ;
356+ } ) ;
357+
358+ it ( 'treats negative wrap as no-wrap' , async ( ) => {
359+ const wrapper = shallowMount ( CodeListing , {
360+ propsData : {
361+ syntax : 'swift' ,
362+ content : [ 'let foo = "bar"' ] ,
363+ wrap : - 5 ,
364+ } ,
365+ } ) ;
366+ await flushPromises ( ) ;
367+
368+ expect ( wrapper . classes ( ) ) . not . toContain ( 'is-wrapped' ) ;
369+ } ) ;
304370} ) ;
0 commit comments