Skip to content

Commit 1c26beb

Browse files
authored
Merge pull request #1099 from dnum-mi/fix/#1067-dsfr-quote
fix: 🐛 affichage de la citation même sans source dans DsfrQuote
2 parents f2cd5ab + a05362d commit 1c26beb

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

src/components/DsfrQuote/DsfrQuote.spec.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

src/components/DsfrQuote/DsfrQuote.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ withDefaults(defineProps<DsfrQuoteProps>(), {
1616
<template>
1717
<figure class="fr-quote fr-quote--column">
1818
<blockquote
19-
v-if="source"
19+
v-if="quote"
2020
:cite="sourceUrl"
2121
>
2222
<p>« {{ quote }} »</p>

0 commit comments

Comments
 (0)