Skip to content

Commit aba34ec

Browse files
authored
Merge pull request #81 from laruiss/feat/dsfr-tags
feat/dsfr tags
2 parents 523638d + d215299 commit aba34ec

24 files changed

+686
-17
lines changed

src/components/DsfrBreadcrumb/DsfrBreadcrumb.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { render } from '@testing-library/vue'
22

33
import DsfrBreadcrumb from './DsfrBreadcrumb.vue'
44

5+
const VIcon = { props: ['name'], template: '<i :class="name"></i>' }
6+
57
describe('DsfrBreadcrumb', () => {
68
it('should render DsfrBreadcrumb with right content', async () => {
79
// Given
@@ -24,6 +26,11 @@ describe('DsfrBreadcrumb', () => {
2426

2527
// When
2628
const { getByRole, findAllByTestId } = render(DsfrBreadcrumb, {
29+
global: {
30+
components: {
31+
VIcon,
32+
},
33+
},
2734
propsData: {
2835
links,
2936
},

src/components/DsfrBreadcrumb/DsfrBreadcrumb.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
:data-testid="`lis`"
2727
>
2828
<router-link
29+
v-if="link.to"
2930
class="fr-breadcrumb__link"
3031
:to="link.to"
3132
:aria-current="index === links.length - 1 ? 'page' : undefined"
3233
>
3334
{{ link.text }}
3435
</router-link>
36+
{{ link.to ? '' : link.text }}
3537
<v-icon
3638
v-if="index !== links.length - 1"
3739
class="icon"
@@ -66,7 +68,7 @@ export default {
6668
},
6769
links: {
6870
type: Array,
69-
default: () => [{ text: 'test' }],
71+
default: () => [{ text: '' }],
7072
},
7173
},
7274
data () {
@@ -188,5 +190,4 @@ export default {
188190
.fade-leave-to {
189191
opacity: 0;
190192
}
191-
192193
</style>

src/components/DsfrButton/DsfrButton.spec.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ import { render } from '@testing-library/vue'
22

33
import DsfrButton from './DsfrButton.vue'
44

5+
const VIcon = { props: ['name'], template: '<i :class="name"></i>' }
6+
57
describe('DsfrButton', () => {
68
it('should mount DsfrButton with right content', () => {
79
// Given
810
const label = 'Button label'
911

1012
// When
1113
const { getByText } = render(DsfrButton, {
14+
global: {
15+
components: {
16+
VIcon,
17+
},
18+
},
1219
slots: {
1320
default: label,
1421
},
@@ -24,6 +31,11 @@ describe('DsfrButton', () => {
2431

2532
// When
2633
const { getByText } = render(DsfrButton, {
34+
global: {
35+
components: {
36+
VIcon,
37+
},
38+
},
2739
props: {
2840
secondary: true,
2941
},
@@ -33,6 +45,6 @@ describe('DsfrButton', () => {
3345
})
3446

3547
// Then
36-
expect(getByText(label)).toHaveClass('fr-btn--secondary')
48+
expect(getByText(label).parentNode).toHaveClass('fr-btn--secondary')
3749
})
3850
})

src/components/DsfrButton/DsfrButton.stories.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export default {
1414
control: 'boolean',
1515
description: 'Indique si le bouton est un bouton **secondaire**',
1616
},
17-
dark: { control: 'boolean', description: 'Permet de voir le composant dans les deux **thèmes** : **clair** (`false`, défaut) et **sombre* (`true`).\n\n*N.B. : Ne fait pas partie du composant.*' },
17+
dark: {
18+
control: 'boolean',
19+
description: 'Permet de voir le composant dans les deux **thèmes** : **clair** (`false`, défaut) et **sombre* (`true`).\n\n*N.B. : Ne fait pas partie du composant.*',
20+
},
1821
label: {
1922
control: 'text',
2023
description: '**Texte** du bouton',

src/components/DsfrCard/DsfrCard.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { render } from '@testing-library/vue'
22

33
import DsfrCard from './DsfrCard.vue'
44

5+
const VIcon = { props: ['name'], template: '<i :class="name"></i>' }
6+
57
describe('DsfrCard', () => {
68
it('should render a nice card', () => {
79
// Given
@@ -17,6 +19,11 @@ describe('DsfrCard', () => {
1719
// When
1820

1921
const { getByText, getByTestId } = render(DsfrCard, {
22+
global: {
23+
components: {
24+
VIcon,
25+
},
26+
},
2027
props: {
2128
altImg,
2229
detail,

src/components/DsfrCheckbox/DsfrCheckbox.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { render } from '@testing-library/vue'
22

33
import CheckBox from './DsfrCheckbox.vue'
44

5+
const VIcon = { props: ['name'], template: '<i :class="name"></i>' }
6+
57
describe('DsfrCheckbox', () => {
68
it('should render a checkbox with label in div', () => {
79
// Given
@@ -10,9 +12,15 @@ describe('DsfrCheckbox', () => {
1012

1113
// When
1214
const { getByText, getByLabelText } = render(CheckBox, {
15+
global: {
16+
components: {
17+
VIcon,
18+
},
19+
},
1320
props: {
1421
label,
1522
modelValue,
23+
name: 'label-1',
1624
},
1725
})
1826

@@ -35,9 +43,15 @@ describe('DsfrCheckbox', () => {
3543

3644
// When
3745
const { getByText, getByLabelText } = render(CheckBox, {
46+
global: {
47+
components: {
48+
VIcon,
49+
},
50+
},
3851
props: {
3952
label,
4053
modelValue,
54+
name: 'label-1',
4155
disabled,
4256
},
4357
})

src/components/DsfrCheckbox/DsfrCheckboxSet.spec.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { fireEvent, render } from '@testing-library/vue'
22

33
import DsfrCheckboxSet from './DsfrCheckboxSet.vue'
44

5+
const VIcon = { props: ['name'], template: '<i :class="name"></i>' }
6+
57
describe('DsfrCheckboxSet', () => {
68
it('should render a group of checkboxes in fieldset', () => {
79
// Given
@@ -35,6 +37,11 @@ describe('DsfrCheckboxSet', () => {
3537

3638
// When
3739
const { getByText, getAllByTestId } = render(DsfrCheckboxSet, {
40+
global: {
41+
components: {
42+
VIcon,
43+
},
44+
},
3845
props: {
3946
legend: legendText,
4047
options,
@@ -58,28 +65,33 @@ describe('DsfrCheckboxSet', () => {
5865
id: '1',
5966
name: 'name1',
6067
label: firstLabelText,
61-
checked: true,
68+
modelValue: true,
6269
hint: firstHintText,
6370
},
6471
{
6572
id: '2',
6673
name: 'name2',
6774
label: secondLabelText,
68-
checked: false,
75+
modelValue: false,
6976
hint: secondHintText,
7077
},
7178
{
7279
id: '3',
7380
name: 'name3',
7481
label: thirdLabelText,
75-
checked: false,
82+
modelValue: false,
7683
hint: thirdHintText,
7784
},
7885
]
7986
const legendText = "Légende de l'ensemble des champs"
8087

8188
// When
8289
const { getByText, getByTestId } = render(DsfrCheckboxSet, {
90+
global: {
91+
components: {
92+
VIcon,
93+
},
94+
},
8395
props: {
8496
legend: legendText,
8597
options,
@@ -91,5 +103,6 @@ describe('DsfrCheckboxSet', () => {
91103
expect(getByTestId('input-checkbox-1')).toBeInTheDocument()
92104
expect(getByTestId('input-checkbox-1')).toHaveAttribute('name', 'name1')
93105
expect(getByTestId('input-checkbox-1').checked).toBe(true)
106+
expect(getByTestId('input-checkbox-2').checked).toBe(false)
94107
})
95108
})

src/components/DsfrHeader/DsfrHeader.spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ import { render } from '@testing-library/vue'
22

33
import DsfrHeader from './DsfrHeader.vue'
44

5+
const VIcon = { props: ['name'], template: '<i :class="name"></i>' }
6+
57
describe('DsfrHeader', () => {
68
it('should render DsfrHeader with a logo', () => {
79
// Given
8-
const logoText = 'Ministère'
10+
const logoText = 'Gouvernement'
911

1012
// When
1113
const { getByText } = render(DsfrHeader, {
14+
global: {
15+
components: {
16+
VIcon,
17+
},
18+
},
1219
slots: {
1320
'logo-text': logoText,
1421
},

src/components/DsfrHeader/DsfrHeader.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import VIcon from 'oh-vue-icons/dist/v3/icon.es'
44
import {
55
RiNotification3Line,
66
RiPhoneLine,
7-
} from 'oh-vue-icons/icons'
7+
} from 'oh-vue-icons/icons/ri/index.js'
88

99
VIcon.add(
1010
RiNotification3Line,

src/components/DsfrLogo/DsfrLogo.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import DsfrLogo from './DsfrLogo.vue'
55
describe('DsfrLogo', () => {
66
it('should render flag, text and motto', () => {
77
// Given
8-
const text = 'République française'
8+
const text = 'Gouvernement'
99

1010
// When
1111
const { getByText } = render(DsfrLogo, {
12-
slots: {
13-
default: text,
12+
props: {
13+
logoText: text,
1414
},
1515
})
1616

0 commit comments

Comments
 (0)