@@ -41,7 +41,55 @@ describe('DsfrQuote', () => {
4141 } )
4242 const imgEl = container . querySelector ( '.fr-responsive-img' )
4343 const quoteEl = container . querySelector ( 'blockquote p' )
44- const citeEl = getByText ( source )
44+ const citeEl = container . querySelector ( 'cite' )
45+ const firstLink = getByText ( 'Détail 1' )
46+ const lastLink = container . querySelectorAll ( '.fr-quote__source li' ) [ details . length ]
47+
48+ expect ( quoteEl ) . toBeInTheDocument ( )
49+ expect ( citeEl ) . toBeInTheDocument ( )
50+ expect ( quoteEl . innerHTML ) . toContain ( quote )
51+ expect ( imgEl ) . toHaveAttribute ( 'src' , quoteImage )
52+ expect ( firstLink ) . not . toHaveAttribute ( 'href' )
53+ expect ( firstLink . innerHTML ) . toContain ( firstSourceText )
54+ expect ( lastLink . querySelector ( 'a' ) ) . toHaveAttribute ( 'href' )
55+ } )
56+ it ( 'should render a complete DsfrQuote even if source is an empty string' , ( ) => {
57+ const quote = 'LA citation'
58+ const author = 'Pierre-Louis EGAUD'
59+ const firstSourceText = 'Détail 1'
60+ const details = [
61+ firstSourceText ,
62+ 'Détail 2' ,
63+ 'Détail 3' ,
64+ {
65+ url : 'https://www.wikipedia.fr' ,
66+ label : 'wikipedia' ,
67+ } ,
68+ ]
69+ const illustration = 'illustration'
70+ const source = ''
71+ const sourceUrl = 'https://www.duckduckgo.com'
72+ const quoteImage = 'https://loremflickr.com/g/150/150/cat?random=1'
73+
74+ const { container, getByText } = render ( DsfrQuote , {
75+ global : {
76+ components : {
77+ VIcon,
78+ } ,
79+ } ,
80+ props : {
81+ quote,
82+ author,
83+ details,
84+ illustration,
85+ source,
86+ sourceUrl,
87+ quoteImage,
88+ } ,
89+ } )
90+ const imgEl = container . querySelector ( '.fr-responsive-img' )
91+ const quoteEl = container . querySelector ( 'blockquote p' )
92+ const citeEl = container . querySelector ( 'cite' )
4593 const firstLink = getByText ( 'Détail 1' )
4694 const lastLink = container . querySelectorAll ( '.fr-quote__source li' ) [ details . length ]
4795
0 commit comments